Title: | Form builder |
---|---|
Description: | Build forms with the command line interface. |
Authors: | Kevin Cazelles [aut, cre] , Nicolas Casajus [aut] |
Maintainer: | Kevin Cazelles <[email protected]> |
License: | GPL-3 |
Version: | 0.0.0.9000 |
Built: | 2024-11-16 04:19:52 UTC |
Source: | https://github.com/inSileco/formbuildr |
Export answers.
export_answer(x, file, format = "yaml")
export_answer(x, file, format = "yaml")
x |
object of class |
file |
file name. |
format |
So far only YAML is available. |
A binary question to be answered by Yes or No.
fob_among(question, choices, field_name = "", output = "choice", ...) fob_month(question, field_name = "", output = c("choice", "id"), ...) fob_weekday(question, field_name = "", output = c("choice", "id"), ...)
fob_among(question, choices, field_name = "", output = "choice", ...) fob_month(question, field_name = "", output = c("choice", "id"), ...) fob_weekday(question, field_name = "", output = c("choice", "id"), ...)
question |
The question to be asked. |
choices |
A vector of choices. |
field_name |
Name of the field (optional). |
output |
Either "choice" or "id". |
... |
further arguments to be passed to |
Return the choice selected either as the choice value or its identifier (an integer).
fob_month
: One month.
fob_weekday
: One weekday.
Generate any kind of question.
fob_any(type, ...)
fob_any(type, ...)
type |
Type of answer expected. |
... |
Further arguments passed to the question function. |
Generate one question.
fob_int(question, field_name = "", prompt = NULL) fob_num(question, field_name = "", prompt = NULL) fob_date(question, field_name = "", format = "%Y-%m-%d", prompt = NULL, ...) fob_char(question, field_name = "", prompt = NULL) fob_yorn(question, field_name = "", prompt = "Enter [Y]es or [N]o:", ...) fob_bool(question, field_name = "", prompt = "Enter [T]RUE or [F]ALSE:", ...)
fob_int(question, field_name = "", prompt = NULL) fob_num(question, field_name = "", prompt = NULL) fob_date(question, field_name = "", format = "%Y-%m-%d", prompt = NULL, ...) fob_char(question, field_name = "", prompt = NULL) fob_yorn(question, field_name = "", prompt = "Enter [Y]es or [N]o:", ...) fob_bool(question, field_name = "", prompt = "Enter [T]RUE or [F]ALSE:", ...)
question |
The question to be asked. |
field_name |
Name of the field (optional). |
prompt |
The string printed when prompting the user for input (see |
format |
Date format. |
... |
Further arguments to be passed to |
one integer.
fob_num
: one numeric.
fob_date
: one date.
fob_char
: a character.
fob_yorn
: TRUE
for yes and FALSE
for no.
fob_bool
: one boolean/logical (i.e. TRUE
or FALSE
).
Add an output.
fob_output(FUN, field_name = NULL)
fob_output(FUN, field_name = NULL)
FUN |
a function a character string that will be displayed. |
field_name |
Field name. |
An object of class output
.
A binary question to be answered by Yes or No.
fob_pattern( question, pattern, field_name = "", prompt = "Enter your answer:", ... )
fob_pattern( question, pattern, field_name = "", prompt = "Enter your answer:", ... )
question |
The question to be asked. |
pattern |
Pattern to be matched. |
field_name |
Name of the field (optional). |
prompt |
The string printed when prompting the user for input (see |
... |
Further arguments passed to |
answer validated.
Add a section.
fob_section(msg)
fob_section(msg)
msg |
a character string that will be displayed. |
A section
object.
A binary question to be answered by Yes or No.
fob_word(question, field_name = "", prompt = NULL, ...) fob_text(question, field_name = "", max = NULL, prompt = NULL, ...) fob_email(question, field_name = "", prompt = NULL, ...)
fob_word(question, field_name = "", prompt = NULL, ...) fob_text(question, field_name = "", max = NULL, prompt = NULL, ...) fob_email(question, field_name = "", prompt = NULL, ...)
question |
The question to be asked. |
field_name |
Name of the field (optional). |
prompt |
the string printed when prompting the user for input (see |
... |
further arguments to be passed to |
max |
maximum of characters (ignored if |
a word.
fob_text
: a character string.
fob_email
: a character string.
Create a form from a connection.
form_from_file(con)
form_from_file(con)
con |
a connection object or a character string (see |
This function reas
q:
question
t:
type
p:
prompt message (optional)
f:
field name (optional)
#'
a section
Functions that generate object of class form_partials
.
generate_form( prompt = "", question = NULL, choices = NULL, validate = NULL, confirm = FALSE, pre = NULL, post = NULL, field_name = "", extra_space = " " ) generate_form_pattern( prompt = "", question = NULL, choices = NULL, pattern = "*", confirm = FALSE, pre = NULL, post = NULL, field_name = "" ) generate_form_choices( prompt = "", question = NULL, choices, confirm = FALSE, pre = NULL, post = NULL, field_name = "" )
generate_form( prompt = "", question = NULL, choices = NULL, validate = NULL, confirm = FALSE, pre = NULL, post = NULL, field_name = "", extra_space = " " ) generate_form_pattern( prompt = "", question = NULL, choices = NULL, pattern = "*", confirm = FALSE, pre = NULL, post = NULL, field_name = "" ) generate_form_choices( prompt = "", question = NULL, choices, confirm = FALSE, pre = NULL, post = NULL, field_name = "" )
prompt |
The string printed when prompting the user for input (see |
question |
The question to be asked. |
choices |
A vector of choices. |
validate |
A function used to validate the answer (see details), if |
confirm |
a logical. Should the answer be confirmed (default is |
pre |
A function for pre-processing. |
post |
A function for post-processing. |
field_name |
Field name (optional) that will be used in the list of answer. |
extra_space |
extra space in prompt line. |
pattern |
pattern to be matched (see |
The object of class form_partial
returned is a function with one argument (x
) that triggers the following actions once called:
displays a question to be asked (question
);
prompts a message (prompt
) that is used to specify the nature of the input;
if confirm = TRUE
then a confirmation messages will be prompted;
(optional) calls the function pre
that transforms the input;
validates the input (validate
), i.e. returns TRUE
if the input (that may have been transformed) is valid;
(optional) applies a function (post
) to the validated input that thereby becomes output
The argument x
of a form_partial
is set to NULL
, it can however be set to a different value. In such case, once the object is called, the interactive steps (the first three steps aforementioned) are skipped and the input goes through the 3 last steps. If the input is not validated then NA
will be returned.
A object of class form_partial
.
generate_form_pattern
: match pattern.
generate_form_choices
: list fo choices.
form_partial
or form
objects of class form_partial
or form
join(...) x %+% y
join(...) x %+% y
... |
object(s) of class |
x , y
|
objects of class |
A form.
%+%
: join operator.
Fill out the same form by multiple participants.
multi(x, n = 1, names = NULL)
multi(x, n = 1, names = NULL)
x |
a object of class |
n |
number of participants. |
names |
participants names. |