save_run {runonce} | R Documentation |
Cache result
Description
Cache the result of code
in an RDS file.
Usage
save_run(code, file, timing = TRUE)
Arguments
code |
Code to run. Do not forget to wrap it with |
file |
File path where the result is stored. Should have extension |
timing |
Whether to print timing of running code? Default is |
Value
The evaluation of code
the first time, the content of file
otherwise.
Examples
# Prepare some temporary file
tmp <- tempfile(fileext = ".rds")
# Run once because result does not exist yet
save_run({
Sys.sleep(2)
1
}, file = tmp)
# Skip run because the result already exists
# (but still output how long it took the first time)
save_run({
Sys.sleep(2)
1
}, file = tmp)
[Package runonce version 0.2.3 Index]