Description Usage Arguments Value Examples
Stash an object after the first time is is created and re-load it the next time. If the code that generates the object is changed or any of its dependencies change, the code is re-evaluated and the new object is stashed.
1 |
var |
A variable to stash (as a string). |
code |
The code to generate the object to be stashed. |
depends_on |
A vector of other objects that this one depends on. Changes to these objects will cause the re-running of the code, next time. |
functional |
If TRUE, return the object rather than setting in the global environment (default FALSE). |
verbose |
Whether to print action statements (default TRUE). |
Returns NULL
(invisibly).
1 2 3 4 5 6 7 8 9 10 11 | # A value that is used to create `rnd_vals`.
x <<- 1e6 # The `<<-` is not normally required, just for this example.
# Stash the results of the comuption of `rnd_vals`.
stash("rnd_vals", depends_on = "x", {
# Some long running computation.
rnd_vals <- rnorm(x)
})
# Remove directory for this example - do not do in real use.
unlink(".mustashe", recursive = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.