Description Usage Arguments Details Value Question types ‘input’ type ‘confirm’ type ‘choose’ type ‘checkbox’ type ‘constant’ type Conditional execution Examples
Ask questions to the user, at the command line, and get the answers
1 |
... |
Questions to ask, see details below. |
.prompt |
Prompt to prepend to all questions. |
Ask a series of questions to the user, and return all results together in a list.
The ask
function takes named arguments only:
Each argument corresponds to a question to the user.
The name of the argument is the identifier of the question, the answer will have the same name in the result list.
Each argument is a function call. The name of the function is the type of the question. See question types below.
Questions are asked in the order they are given. See ‘Conditional execution’ below for more flexible workflows.
A named list with the answers.
One line of text input.
A yes-no question, ‘y’ and ‘yes’ are considered as positive, ‘n’ and ‘no’ as negative answers (case insensitively).
Choose one item form multiple items.
Select multiple values from a list.
Not a question, it defines constants.
1 2 |
message
The message to print.
default
The default vaue to return if the user just presses enter.
filter
If not NULL
, then it must be a function,
that is called to filter the entered result.
validate
If not NULL
, then it must be a function
that is called to validate the input. The function must return
TRUE
for valid inputs and an error message (character scalar)
for invalid ones.
when
See ‘Conditional execution’ below.
1 |
message
The message to print.
default
The default answer if the user just presses enter.
when
See ‘Conditional execution’ below.
1 |
message
Message to print.
choices
Possible choices, character vector.
default
Index or value of the default choice (if the user
hits enter, or NA
for no default. Values are matched using
partial matches via pmatch
.
when
See ‘Conditional execution’ below.
1 |
message
Message to print.
choices
Possible choices, character vector.
default
Indices or values of default choices.
values are matches using partial matches via pmatch
.
when
See ‘Conditional execution’ below.
1 |
constant_value
The constant value. Note that the argument must be named.
when
See ‘Conditional execution’ below.
The when
argument to a question can be used for conditional
execution of questions. If it is given (and not NULL
), then
it must be a function. It is called with the answers list up to that
point, and it should return TRUE
or FALSE
. For TRUE
,
the question is shown to the user and the result is inserted into the
answer list. For FALSE
, the question is not shown, and the
answer list is not chagned.
1 2 3 4 5 6 7 8 9 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.