dput                  package:base                  R Documentation

_W_r_i_t_e _a_n _O_b_j_e_c_t _t_o _a _F_i_l_e _o_r _R_e_c_r_e_a_t_e _i_t

_D_e_s_c_r_i_p_t_i_o_n:

     Writes an ASCII text representation of an R object to a file or
     connection, or uses one to recreate the object.

_U_s_a_g_e:

     dput(x, file = "",
          control = c("keepNA", "keepInteger", "showAttributes"))

     dget(file)

_A_r_g_u_m_e_n_t_s:

       x: an object.

    file: either a character string naming a file or a connection. '""'
          indicates output to the console.

 control: character vector indicating deparsing options. See
          '.deparseOpts' for their description.

_D_e_t_a_i_l_s:

     'dput' opens 'file' and deparses the object 'x' into that file. 
     The object name is not written (unlike 'dump'). If 'x' is a
     function the associated environment is stripped. Hence scoping
     information can be lost.

     Deparsing an object is difficult, and not always possible.  With
     the default 'control', 'dput()' attempts to deparse in a way that
     is readable, but for more complex or unusual objects (see 'dump',
     not likely to be parsed as identical to the original.  Use
     'control = "all"' for the most complete deparsing; use 'control =
     NULL' for the simplest deparsing, not even including attributes.

     'dput' will warn if fewer characters were written to a file than
     expected, which may indicate a full or corrupt file system.

     To display saved source rather than deparsing the internal
     representation  include '"useSource"' in 'control'.  R currently
     saves source only for function definitions.

_V_a_l_u_e:

     For 'dput', the first argument invisibly.

     For 'dget', the object created.

_N_o_t_e:

     To avoid the risk of a source attribute out of sync with the
     actual function definition, the source attribute of a function
     will never  be written as an attribute.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'deparse', 'dump', 'write'.

_E_x_a_m_p_l_e_s:

     ## Write an ASCII version of mean to the file "foo"
     dput(mean, "foo")
     ## And read it back into 'bar'
     bar <- dget("foo")
     unlink("foo")
     ## Create a function with comments
     baz <- function(x) {
       # Subtract from one
       1-x
     }
     ## and display it
     dput(baz)
     ## and now display the saved source
     dput(baz, control = "useSource")

