ask.user.yn.question: Asks the user for one yes/no question.

View source: R/updateR.R

ask.user.yn.questionR Documentation

Asks the user for one yes/no question.

Description

Asks the user for one yes/no question. If the users replies with a "yes" (or Y, or y) the function returns TRUE. Otherwise, FALSE. (also exists as the function devtools::yesno)

Usage

ask.user.yn.question(question, GUI = TRUE, add_lines_before = TRUE)

Arguments

question

a character string with a question to the user.

GUI

a logical indicating whether a graphics menu should be used if available. If TRUE, and on Windows, it will use winDialog, otherwise it will use menu.

add_lines_before

if to add a line before asking the question. Default is TRUE.

Value

TRUE/FALSE - if the user answers yes or no.

References

https://stackoverflow.com/questions/15250487/how-to-add-a-menu-item-to-rgui (my thanks goes to Dason for his answer and help)

See Also

menu in the utils package, yesno in the devtools package.

Examples

## Not run: 
ask.user.yn.question("Do you love R?")
ask.user.yn.question(question = "Do you love R?", GUI = TRUE) # the same one as before
ask.user.yn.question(question = "Do you love R?", GUI = FALSE) 
# reverts to command line questions

ask.user.yn.question("Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
Ut enim ad minim veniam, quis nostrud exercitation

  ullamco laboris nisi ut aliquip 
  ex ea commodo consequat. Do \n you \n love R?")
   # checking how it deals with multi lines, and a lot of text (very good actually)
  

## End(Not run)

installr documentation built on Nov. 13, 2022, 1:06 a.m.