reload.or.compute

0th

Percentile

Compute Unless Previously Saved

If the designated file does not yet exist, evaluate the expression and save the results in the file. If the file already exists, re-load the results from the file.

Keywords
utilities
Usage
reload.or.compute(filename, expr, objects = NULL, destination = parent.frame())
Arguments
filename
Name of data file. A character string.
expr
Rlanguage expression to be evaluated.
objects
Optional character vector of names of objects to be saved in filename after evaluating expr, or names of objects that should be present in filename when loaded.
destination
Environment in which the resulting objects should be assigned.
Details

This facility is useful for saving, and later re-loading, the results of time-consuming computations. It would typically be used in an Rscript file or an 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.

Value

  • Character vector (invisible) giving the names of the objects computed or loaded.

Aliases
  • reload.or.compute
Examples
reload.or.compute("mydata.rda", {
        x <- very.long.computation()
        y <- 42
      })
Documentation reproduced from package spatstat, version 1.36-0, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.