A simple function to detect input from the user, and keep prompting until a response matching the class of input required is given.
ask(prompt = "?", type = "logical", bounds = c(-Inf, Inf), na.allow = FALSE)
what text string should be used to prompt the user? (character string)
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
the lower and upper bounds of number to be returned. Ignored if type is "logical" or "character".
if TRUE, allows the user to input "NA" for any type, which is returned as NA