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

ask

Obtain Input from User With Error Handling


Description

A simple function to detect input from the user, and keep prompting until a response matching the class of input required is given.

Usage

ask(prompt = "?", type = "logical", bounds = c(-Inf, Inf), na.allow = FALSE)

Arguments

prompt

what text string should be used to prompt the user? (character string)

type

the class of object expected to be returned - "logical", "numeric", "integer", "character". If the user input does not match this return, the prompt is repeated

bounds

the lower and upper bounds of number to be returned. Ignored if type is "logical" or "character".

na.allow

if TRUE, allows the user to input "NA" for any type, which is returned as NA

See Also


runjags

Interface Utilities, Model Templates, Parallel Computing Methods and Additional Distributions for MCMC Models in JAGS

v2.2.0-2
GPL-2
Authors
Matthew Denwood [aut, cre], Martyn Plummer [cph] (Copyright holder of the code in src/distributions/DPar1.*, configure.ac, R/rjags_functions.R, and original copyright holder of some modified code where indicated)
Initial release
2021-03-01

We don't support your browser anymore

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