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

