Skip to contents

A modified version of save.image that allows to save the commands history and the list of attached packages. See save.image for the function details.

Usage

save.image(
  file = ".RData",
  version = NULL,
  ascii = FALSE,
  compress = !ascii,
  safe = TRUE,
  hist = TRUE,
  h.file = ".Rhistory",
  pkglist = TRUE,
  p.file = ".Rpackages"
)

Arguments

file

A (writable binary-mode) connection or the name of the file where the data will be saved (when tilde expansion is done). Must be a file name for ‘save.image’ or ‘version = 1’.

version

The workspace format version to use. NULL specifies the current default format (3). Version 1 was the default from R 0.99.0 to R 1.3.1 and version 2 from R 1.4.0 to 3.5.0. Version 3 is supported from R 3.5.0.

ascii

If ‘TRUE’, an ASCII representation of the data is written. The default value of ‘ascii’ is ‘FALSE’ which leads to a binary file being written. If ‘NA’ and ‘version >= 2’, a different ASCII representation is used which writes double/complex numbers as binary fractions.

compress

Logical or character string specifying whether saving to a named file is to use compression. ‘TRUE’ corresponds to ‘gzip’ compression, and character strings ‘"gzip"’, ‘"bzip2"’, ‘"xz"’ or ‘"zstd"’ specify the type of 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.

hist

Logical. Whether to save or not the commands history.

h.file

The name of the file in which to save the history, or from which to load it. The path is relative to the current working directory.

pkglist

Logical. Whether to save or not the list of attached packages (default is TRUE).

p.file

The name of the file in which to save the list of attached packages, or from which to load it. The path is relative to the current working directory.

See also

savehistory to save the commands history, and savepkglist to save the list of attached packages.

Author

R Core Team, modified by Mathieu Basille <\email{mathieu@basille.org}>

Examples

if (FALSE) { # \dontrun{
## Save the current workspace in file '.RData' together with the history in
## '.Rhistory' and the package list in '.Rpackages':
save.image()} # }