depcache-package {depcache} | R Documentation |
Cache R Expressions, Taking Their Dependencies into Account
Description
Hash an expression with its dependencies and store its value, reloading it from a file as long as both the expression and its dependencies stay the same.
Details
The functions in this package take an expression, walk its code to find its dependencies and calculate a hash of them. If a corresponding file already exists, it is loaded; otherwise, the expression is evaluated and its value is saved in the file. Optionally, this check may be performed every time a variable is accessed.
By default, a subdirectory of the current directory is used to store the cache files.
Index of help topics:
cache Evaluate an expression and cache its results depcache-package Cache R Expressions, Taking Their Dependencies into Account depcache.options Caching options setCached Cache-tracking assignment
Author(s)
Ivan Krylov
References
FNV-1a hash: http://www.isthe.com/chongo/tech/comp/fnv/
See Also
Examples
a <- 1
# will evaluate expression
cache({ message('evaluating expression'); a + 1 }) # 2
# will reuse cached value
x %<-% { message('evaluating expression'); a + 1 } # 2
x
a <- 2
# will recalculate the value
x # 3
[Package depcache version 0.1-2 Index]