Title: | Execute Expensive Operations Only Once |
Version: | 0.4.1 |
Description: | Allows you to easily execute expensive compute operations only once, and save the resulting object to disk. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.1 |
Imports: | magrittr (≥ 2.0.3) |
URL: | https://gdmcdonald.github.io/once/ |
NeedsCompilation: | no |
Packaged: | 2022-08-31 00:28:10 UTC; gordon |
Author: | Gordon McDonald |
Maintainer: | Gordon McDonald <gordon.mcdonald@sydney.edu.au> |
Repository: | CRAN |
Date/Publication: | 2022-08-31 19:20:06 UTC |
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling rhs(lhs)
.
Execute Expensive Operations Only Once
Description
The once()
function allows you to easily execute expensive compute operations only once, and save the resulting object to disk.
Usage
once(expr, file_path = NULL, rerun = FALSE)
Arguments
expr |
The expensive expression to evaluate |
file_path |
File path for saving the output object as an Rds file. Note that if no file name is provided it will not save! |
rerun |
Rerun the expression anyway and save the result? Defaults to false. |
Value
the results of expr
Examples
save_file <- tempfile(fileext = ".Rds")
# temporary file path - replace with your preferred saved file path
my_out <-
runif(1e8) %>% # some expensive operation
mean() %>%
once(file_path = save_file)
# only do it once, save output to this file.