Learn R Programming

matlab2r (version 1.5.0)

questdlg: Prompt for multiple-choice

Description

This function aims to loosely mimic the behavior of the questdlg function on Matlab

Usage

questdlg(
  quest,
  dlgtitle = "",
  btn = c("y", "n"),
  defbtn = "n",
  accepted_ans = c("y", "yes", "n", "no")
)

Value

Whatever is entered by the user after the prompt created by the function.

Arguments

quest

Question

dlgtitle

Title of question

btn

Vector of alternatives

defbtn

Scalar with the name of the default option

accepted_ans

Vector containing accepted answers

Examples

Run this code
if (FALSE) {
  ans <- questdlg("Do you want to continue?", "Continue?")
  if (tolower(substring(ans, 1, 1)) == "y") {
    message("You typed yes")
  } else {
    message("You didn't type yes")
  }
}

Run the code above in your browser using DataLab