capture.output             package:utils             R Documentation

_S_e_n_d _o_u_t_p_u_t _t_o _a _c_h_a_r_a_c_t_e_r _s_t_r_i_n_g _o_r _f_i_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     Evaluates its arguments with the output being returned as a
     character string or sent to a file. Related to 'sink' in the same
     way that 'with' is related to 'attach'.

_U_s_a_g_e:

     capture.output(..., file = NULL, append = FALSE)

_A_r_g_u_m_e_n_t_s:

     ...: Expressions to be evaluated

    file: A file name or a connection, or 'NULL' to return the output
          as a string. If the connection is not open it will be opened
          and then closed on exit.

  append: Append or overwrite the file? 

_V_a_l_u_e:

     A character string, or 'NULL' if a 'file' argument was supplied.

_S_e_e _A_l_s_o:

     'sink', 'textConnection'

_E_x_a_m_p_l_e_s:

     require(stats)
     glmout <- capture.output(example(glm))
     glmout[1:5]
     capture.output(1+1, 2+2)
     capture.output({1+1; 2+2})
     ## Not run: 
     ## on Unix with enscript available
     ps <- pipe("enscript -o tempout.ps","w")
     capture.output(example(glm), file=ps)
     close(ps)
     ## End(Not run)

