readline                package:base                R Documentation

_R_e_a_d _a _L_i_n_e _f_r_o_m _t_h_e _T_e_r_m_i_n_a_l

_D_e_s_c_r_i_p_t_i_o_n:

     'readline' reads a line from the terminal

_U_s_a_g_e:

     readline(prompt = "")

_A_r_g_u_m_e_n_t_s:

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

_D_e_t_a_i_l_s:

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

_V_a_l_u_e:

     A character vector of length one.

_E_x_a_m_p_l_e_s:

     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()

