The R Project SVN R

Rev

Rev 61433 | Rev 64328 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61433 Rev 62331
Line 1... Line 1...
1
% File src/library/base/man/save.Rd
1
% File src/library/base/man/save.Rd
2
% Part of the R package, http://www.R-project.org
2
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2011 R Core Team
3
% Copyright 1995-2013 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{save}
6
\name{save}
7
\alias{save}
7
\alias{save}
8
\alias{save.image}
8
\alias{save.image}
Line 11... Line 11...
11
  \code{save} writes an external representation of \R objects to the
11
  \code{save} writes an external representation of \R objects to the
12
  specified file.  The objects can be read back from the file at a later
12
  specified file.  The objects can be read back from the file at a later
13
  date by using the function \code{load} (or \code{data} in some cases).
13
  date by using the function \code{load} (or \code{data} in some cases).
14
 
14
 
15
  \code{save.image()} is just a short-cut for \sQuote{save my current
15
  \code{save.image()} is just a short-cut for \sQuote{save my current
16
    workspace},
-
 
17
  i.e., \code{save(list = ls(all = TRUE), file = ".RData")}.  It is also what
16
    workspace}, i.e., \code{save(list = ls(all = TRUE), file =
18
  happens with \code{\link{q}("yes")}.
17
    ".RData")}.  It is also what happens with \code{\link{q}("yes")}.
19
}
18
}
20
\usage{
19
\usage{
21
save(\dots, list = character(),
20
save(\dots, list = character(),
22
     file = stop("'file' must be specified"),
21
     file = stop("'file' must be specified"),
23
     ascii = FALSE, version = NULL, envir = parent.frame(),
22
     ascii = FALSE, version = NULL, envir = parent.frame(),
Line 32... Line 31...
32
    character strings).}
31
    character strings).}
33
  \item{list}{A character vector containing the names of objects to be
32
  \item{list}{A character vector containing the names of objects to be
34
    saved.}
33
    saved.}
35
  \item{file}{a (writable binary-mode) \link{connection} or the name of the
34
  \item{file}{a (writable binary-mode) \link{connection} or the name of the
36
    file where the data will be saved (when \link{tilde expansion}
35
    file where the data will be saved (when \link{tilde expansion}
37
    is done).  Must be a file name for \code{version = 1}.}
36
    is done).  Must be a file name for \code{save.image} or
-
 
37
    \code{version = 1}.}
38
  \item{ascii}{if \code{TRUE}, an ASCII representation of the data is
38
  \item{ascii}{if \code{TRUE}, an ASCII representation of the data is
39
    written.  The default value of \code{ascii} is \code{FALSE} which
39
    written.  The default value of \code{ascii} is \code{FALSE} which
40
    leads to a binary file being written.}
40
    leads to a binary file being written.}
41
  \item{version}{the workspace format version to use.  \code{NULL}
41
  \item{version}{the workspace format version to use.  \code{NULL}
42
    specifies the current default format.  The version used from \R
42
    specifies the current default format.  The version used from \R
43
    0.99.0 to \R 1.3.1 was version 1.  The default format as from \R
43
    0.99.0 to \R 1.3.1 was version 1.  The default format as from \R
44
    1.4.0 is version 2.}
44
    1.4.0 is version 2.}
45
  \item{envir}{environment to search for objects to be saved.}
45
  \item{envir}{environment to search for objects to be saved.}
46
  \item{compress}{logical or character string specifying whether saving
46
  \item{compress}{logical or character string specifying whether saving
47
    to a named file is to use compression.  \code{TRUE} corresponds to
47
    to a named file is to use compression.  \code{TRUE} corresponds to
48
    \command{gzip} compression, and (from \R 2.10.0) character strings
48
    \command{gzip} compression, and character strings \code{"gzip"},
49
    \code{"gzip"}, \code{"bzip2"} or \code{"xz"} specify the
49
    \code{"bzip2"} or \code{"xz"} specify the type of
50
    type of compression.  Ignored when \code{file} is a connection
50
    compression.  Ignored when \code{file} is a connection and
51
    and for workspace format version 1.}
51
    for workspace format version 1.} 
52
  \item{compression_level}{integer: the level of compression to be
52
  \item{compression_level}{integer: the level of compression to be
53
    used.  Defaults to \code{6} for \command{gzip} compression and to
53
    used.  Defaults to \code{6} for \command{gzip} compression and to
54
    \code{9} for \command{bzip2} or \command{xz} compression.}
54
    \code{9} for \command{bzip2} or \command{xz} compression.}
55
  \item{eval.promises}{logical: should objects which are promises be
55
  \item{eval.promises}{logical: should objects which are promises be
56
    forced before saving?}
56
    forced before saving?}
Line 85... Line 85...
85
  \code{save.image}), see also the \sQuote{Examples} section.  If a
85
  \code{save.image}), see also the \sQuote{Examples} section.  If a
86
  \code{"save.image.defaults"} option is set it is used in preference to
86
  \code{"save.image.defaults"} option is set it is used in preference to
87
  \code{"save.defaults"} for function \code{save.image} (which allows
87
  \code{"save.defaults"} for function \code{save.image} (which allows
88
  this to have different defaults).
88
  this to have different defaults).
89
 
89
 
90
  A connection that is not already open will be opened in mode
90
  A connection that is not already open will be opened in mode \code{"wb"}.
91
  \code{"wb"}.
-
 
92
}
91
}
93
 
92
 
94
\section{Compression}{
93
\section{Compression}{
95
  Large files can be reduced considerably in size by compression.  A
94
  Large files can be reduced considerably in size by compression.  A
96
  particular 46MB dataset was saved as 35MB without compression in 2
95
  particular 46MB object was saved as 35MB without compression in 2
97
  seconds, 22MB with \command{gzip} compression in 8 secs, 19MB with
96
  seconds, 22MB with \command{gzip} compression in 8 secs, 19MB with
98
  \command{bzip2} compression in 13 secs and 9.4MB with \command{xz}
97
  \command{bzip2} compression in 13 secs and 9.4MB with \command{xz}
99
  compression in 40 secs.  The load times were 1.3, 2.8, 5.5 and 5.7
98
  compression in 40 secs.  The load times were 1.3, 2.8, 5.5 and 5.7
100
  seconds respectively.  These results are indicative, but the relative
99
  seconds respectively.  These results are indicative, but the relative
101
  performances do depend on the actual file and \command{xz} did
100
  performances do depend on the actual file: \command{xz} compressed
102
  unusually well here.
101
  unusually well here.
103
 
102
 
104
  It is possible to compress later (with \command{gzip}, \command{bzip2}
103
  It is possible to compress later (with \command{gzip}, \command{bzip2}
105
  or \command{xz}) a file saved with \code{compress = FALSE}: the effect
104
  or \command{xz}) a file saved with \code{compress = FALSE}: the effect
106
  is the same as saving with compression.  Also, a saved file can be
105
  is the same as saving with compression.  Also, a saved file can be
Line 116... Line 115...
116
    In addition: Warning message:
115
    In addition: Warning message:
117
    In gzfile(file, "wb") :
116
    In gzfile(file, "wb") :
118
      cannot open compressed file '.RDataTmp',
117
      cannot open compressed file '.RDataTmp',
119
      probable reason 'Permission denied'
118
      probable reason 'Permission denied'
120
}
119
}
121
 
-
 
122
  The defaults were changed to use compressed saves for \code{save} in
-
 
123
  2.3.0 and for \code{save.image} in 2.4.0.  Any recent version of \R
-
 
124
  can read compressed save files, and a compressed file can be
-
 
125
  uncompressed (by \code{gzip -d}) for use with very old versions of \R.
-
 
126
#ifdef windows
120
#ifdef windows
127
 
121
 
128
  \code{file} can be a UTF-8-encoded filepath that cannot be translated to
122
  \code{file} can be a UTF-8-encoded filepath that cannot be translated to
129
  the current locale.
123
  the current locale.
130
#endif
124
#endif