once | R Documentation |
The once()
function allows you to easily execute expensive compute operations only once, and save the resulting object to disk.
once(expr, file_path = NULL, rerun = FALSE)
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. |
the results of expr
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.