readline {base} | R Documentation |
readline
reads a line from the terminal, returning it as a
character string.
readline()
fun <- function() {
cat("Are you a satisfied R user? ")
ANSWER <- readline()
if (substr(ANSWER, 1, 1) == "n")
cat("This is impossible. YOU LIED!\n")
else
cat("I knew it.\n")
}
fun()