readline                package:base                R Documentation

Read a Line from the Terminal

Description:

     'readline' reads a line from the terminal

Usage:

     readline(prompt = "")

Arguments:

  prompt: the string printed when prompting the user for input. Should
          usually end with a space '" "'.

Details:

     The prompt string will be truncated to a maximum allowed length,
     normally 256 chars (but can be changed in the source code).

Value:

     A character vector of length one.

See Also:

     'readLines' for reading text lines of connections, including
     files.

Examples:

     fun <- function() {
       ANSWER <- readline("Are you a satisfied R user? ")
       if (substr(ANSWER, 1, 1) == "n")
         cat("This is impossible.  YOU LIED!\n")
       else
         cat("I knew it.\n")
     }
     fun()

