reload.or.compute(filename, expr, objects = NULL, destination = parent.frame())filename after evaluating expr,
or names of objects that should be present in filename
when loaded.Sweave document. If the file called filename does not yet exist,
then expr will be evaluated
and the results will be saved in filename.
The optional argument objects specifies which results should be saved
to the file: the default is to save all objects that were created
by evaluating the expression.
If the file called filename already exists, then it
will be loaded. The optional argument objects specifies the names
of objects that should be present in the file; a warning is issued
if any of them are missing.
The resulting objects can be assigned into any desired destination.
The default behaviour is equivalent to evaluating expr
in the current environment.
reload.or.compute("mydata.rda", {
x <- very.long.computation()
y <- 42
})Run the code above in your browser using DataLab