readline reads a line from the terminal (in interactive use).
readline(prompt = "")
| Parameter | Description |
|---|---|
prompt |
the string printed when prompting the user for input. Should usually end with a space " ". |
# NOT RUN {
fun <- function() {
ANSWER <- readline("Are you a satisfied R user? ")
## a better version would check the answer less cursorily, and
## perhaps re-prompt
if (substr(ANSWER, 1, 1) == "n")
cat("This is impossible. YOU LIED!\n")
else
cat("I knew it.\n")
}
if(interactive()) fun()
# }