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

