This function is an improved version of userQuery from Bioconductor Biobase package, which asks the user about some task that needs her intervention to proceed, e.g., ask if one should perform a computation, install a package, etc..

askUser(
  msg,
  allowed = c("y", "n"),
  idefault = "n",
  default = "n",
  case.sensitive = FALSE
)

Arguments

msg

The output message

allowed

Allowed input from the user

idefault

default response in interactive mode. This answer will be in upper case in the question and will be the one returned if the user simply hits return.

default

default response in non-interactive mode.

If NA, then the user is forced to provide an answer, even in non-interactive mode (e.g., when run through Rscript).

case.sensitive

Is the response case sensitive? Defaults to FALSE

Value

the character string typed/agreed by the user or directly the default answer in non-interactive mode.