Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ui-questions

User interface - Questions


Description

These functions are used to interact with the user by posing a simple yes or no question. For details on the other ui_*() functions, see the ui help page.

Usage

ui_yeah(
  x,
  yes = c("Yes", "Definitely", "For sure", "Yup", "Yeah", "I agree", "Absolutely"),
  no = c("No way", "Not now", "Negative", "No", "Nope", "Absolutely not"),
  n_yes = 1,
  n_no = 2,
  shuffle = TRUE,
  .envir = parent.frame()
)

ui_nope(
  x,
  yes = c("Yes", "Definitely", "For sure", "Yup", "Yeah", "I agree", "Absolutely"),
  no = c("No way", "Not now", "Negative", "No", "Nope", "Absolutely not"),
  n_yes = 1,
  n_no = 2,
  shuffle = TRUE,
  .envir = parent.frame()
)

Arguments

x

A character vector.

For block styles, conditions, and questions, each element of the vector becomes a line, and the result is processed by glue::glue(). For inline styles, each element of the vector becomes an entry in a comma separated list.

yes

A character vector of "yes" strings, which are randomly sampled to populate the menu.

no

A character vector of "no" strings, which are randomly sampled to populate the menu.

n_yes

An integer. The number of "yes" strings to include.

n_no

An integer. The number of "no" strings to include.

shuffle

A logical. Should the order of the menu options be randomly shuffled?

.envir

Used to ensure that glue::glue() gets the correct environment. For expert use only.

Value

A logical. ui_yeah() returns TRUE when the user selects a "yes" option and FALSE otherwise, i.e. when user selects a "no" option or refuses to make a selection (cancels). ui_nope() is the logical opposite of ui_yeah().

See Also

Other user interface functions: ui

Examples

## Not run: 
ui_yeah("Do you like R?")
ui_nope("Have you tried turning it off and on again?", n_yes = 1, n_no = 1)
ui_yeah("Are you sure its plugged in?", yes = "Yes", no = "No", shuffle = FALSE)

## End(Not run)

usethis

Automate Package and Project Setup

v2.0.1
MIT + file LICENSE
Authors
Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>), Jennifer Bryan [aut, cre] (<https://orcid.org/0000-0002-6983-2759>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.