This facility is useful for saving, and later re-loading, the results of
time-consuming computations. It would typically be
used in an R script file or an Sweave
document.
If the file called filename
does not yet exist
(or if force=TRUE
),
then expr
will be evaluated
and the results will be saved in filename
using save
.
By default, all objects that were created by evaluating the expression
will be saved in the file.
The optional argument objects
specifies which results should be saved
to the file. The optional argument exclude
specifies results which should not be saved.
If the file called filename
already exists
(and if force=FALSE
, the default), then this file
will be loaded into R using load
.
The optional argument objects
specifies the names
of objects that must be present in the file; a warning is issued
if any of them are missing.
The resulting objects (either evaluated or loaded from file)
can be assigned into any desired
destination
environment.
The default behaviour is equivalent to evaluating expr
in the current environment.
If force=TRUE
then expr
will be evaluated
(regardless of whether the file already exists or not)
and the results will be saved in filename
, overwriting
any previously-existing file with that name. This is a convenient
way to force the code to re-compute everything
in an R script file or Sweave
document.