save                  package:base                  R Documentation

_S_a_v_e _R _O_b_j_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     `save' writes a external representation of R objects to the
     specified file.  The objects can be read back from the file at a
     later date by using the function `load' (or `data' in some cases).

     `save.image()' is just a short-cut for ``save my current
     environment'', i.e., `save(list = ls(all=TRUE), file = ".RData")'.
     It is what also happens with `q("yes")'.

_U_s_a_g_e:

     save(..., list = character(0), file = "", ascii = FALSE,
          version = NULL, envir = parent.frame(), compress = FALSE)
     save.image(file = ".RData", version = NULL, ascii = FALSE,
                compress = FALSE, safe = TRUE)

     sys.load.image(name, quiet)
     sys.save.image(name)

_A_r_g_u_m_e_n_t_s:

     ...: the names of the objects to be saved.

    list: A character vector containing the names of objects to be
          saved.

    file: a connection or the name of the file where the data will be
          saved.  Must be a file name for workspace format version 1.

   ascii: if `TRUE', an ASCII representation of the data is written. 
          This is useful for transporting data between machines of
          different types.  The default value of `ascii' is `FALSE'
          which leads to a more compact binary file being written.

 version: the workspace format version to use.  NULL specifies the
          current default format.  The version used from R 0.99.0 to R
          1.3.1 was version 1.  The default format as from R 1.4.0 is
          version 2.

   envir: environment to search for objects to be saved.

compress: logical specifying whether saving to a named file is to use
          compression. Ignored when `file' is a connection and for
          workspace format version 1.

    safe: logical.  If TRUE, a temporary file is used for creating the
          saved workspace.  The temporary file is renamed to `file' if
          the save succeeds.  This preserves an existing workspace
          `file' if the save fails, but at the cost of using extra disk
          space during the save.

    name: name of image file to save or load.

   quiet: logical specifying whether a message should be printed.

_D_e_t_a_i_l_s:

     All R platforms use the XDR representation of binary objects in
     binary save-d files, and these are portable across all R
     platforms.

     Default values for `save.image' options can be modified with the
     `save.image.defaults' option.  This mechanism is experimental and
     subject to change.

     `sys.save.image' is a system function that is called by `q()' and
     its GUI analogs; `sys.load.image' is called by the startup code.
     These functions should not be called directly and are subject to
     change.

_S_e_e _A_l_s_o:

     `dput', `dump', `load', `data'.

_E_x_a_m_p_l_e_s:

     x <- runif(20)
     y <- list(a = 1, b = TRUE, c = "oops")
     save(x, y, file = "xy.Rdata")
     save.image()
     unlink("xy.Rdata")
     unlink(".RData")

     # set save.image defaults using option:
     options(save.image.defaults=list(ascii=TRUE, safe=FALSE))
     save.image()
     unlink(".RData")

