pushBack                package:base                R Documentation

_P_u_s_h _T_e_x_t _B_a_c_k _o_n _t_o _a _C_o_n_n_e_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Functions to push back text lines onto a connection, and to
     enquire how many lines are currently pushed back.

_U_s_a_g_e:

     pushBack(data, connection, newLine = TRUE)
     pushBackLength(connection)

_A_r_g_u_m_e_n_t_s:

    data: a character vector.

connection: A connection.

 newLine: logical. If true, a newline is appended to each string pushed
          back.

_D_e_t_a_i_l_s:

     Several character strings can be pushed back on one or more
     occasions. The occasions form a stack, so the first line to be
     retrieved will be the first string from the last call to
     `pushBack'.  Lines which are pushed back are read prior to the
     normal input from the connection, by the normal text-reading
     functions such as `readLines' and `scan'.

     Pushback is only allowed for readable connections.

     Not all uses of connections respect pushbacks, in particular the
     input connection is still wired directly, so for example parsing
     commands from the console and `scan("")' ignore pushbacks on
     `stdin'.

_V_a_l_u_e:

     `pushBack' returns nothing.

     `pushBackLength' returns number of lines currently pushed back.

_S_e_e _A_l_s_o:

     `connections', `readLines'.

_E_x_a_m_p_l_e_s:

     zz <- textConnection(LETTERS)
     readLines(zz, 2)
     pushBack(c("aa", "bb"), zz)
     pushBackLength(zz)
     readLines(zz, 1)
     pushBackLength(zz)
     readLines(zz, 1)
     readLines(zz, 1)
     close(zz)

