cacheSweave: Cache Sweave Computations

Description Usage Details Value Note Author(s) See Also Examples

Description

Cache computations when using Sweave

Usage

1
2

Details

Computations in Sweave documents can be cached by setting the option cache=true in the code check declaration. When this option is set, objects that are created in the code chunk (either through assignment or by side effects) are stored in a key-value database in the directory specified by setCacheDir.

Caching and dependencies is implemented by storing chunks modification time in a metadata database. To use dependencies label your dependencies and refer to them using the syntax dependson=A;B. See example. You can add trace information to your output file using the option trace=true. This will show the modification times of the chunks and whether cached or newly evaluated chunks are being used.

The cacheSweaveDriver function is used directly with Sweave and is passed as the driver argument. For tangling the cacheTangleDriver needs to be used if you have dependencies in your source file.

Value

Nothing useful is returned.

Note

Code chunks that have side effects that do not result in objects being created in the global environment (i.e. plotting or system interaction) should generally not be cached since the code will not be run upon reevaluation.

Author(s)

Roger D. Peng rpeng@jhsph.edu, with much code for cacheSweaveDriver copied from Sweave source by Friedrich Leisch

See Also

Sweave and package RRPM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
<<A,cache=true>>=
x <- rnorm(100)
@
<<B,cache=true>>=
y <- rnorm(100)
@
<<C,cache=true,dependson=A;B>>=
print(sum(x,y))
@

## End(Not run)

rdpeng/cachesweave documentation built on May 27, 2019, 3:06 a.m.