askYesNo {utils} | R Documentation |
askYesNo
provides a standard way to ask the user a yes/no question.
It provides a way for front-ends to substitute their own dialogs.
askYesNo(msg, default = TRUE,
prompts = getOption("askYesNo", gettext(c("Yes", "No", "Cancel"))),
...)
msg |
The prompt message for the user. |
default |
The default response. |
prompts |
Any of: a character vector containing 3 prompts corresponding to
return values of |
... |
Additional parameters, ignored by the default function. |
askYesNo
will accept case-independent partial matches to the prompts.
If no response
is given the value of default
will be returned; if a non-empty
string that doesn't match any of the prompts is entered, an error will be
raised.
If a function or single character string naming a function
is given for prompts
, it will be called as
fn(msg = msg, default = default, prompts = prompts, ...)
. On
Windows, the GUI uses the unexported utils:::askYesNoWinDialog
function for this purpose.
If strings (or a string such as "Y/N/C"
) are given as prompts
,
the choices will be mapped to lowercase for the non-default choices, and
left as-is for the default choice.
TRUE
for yes, FALSE
for no, and NA
for cancel.
readline
for more general user input.
if (interactive())
askYesNo("Do you want to use askYesNo?")