cache | R Documentation |
Cache or retrieve an evaluated expression. Results are always made available in the current environment.
cache(..., .cachedir = here(".cache-R"), .rerun = FALSE)
... |
Named expressions to be cached or retrieved. |
.cachedir |
Directory where cache files are stored. Default is a directory called |
.rerun |
Whether or not to clear the cache and re-run the provided expressions. Defaults to FALSE. |
tmp <- tempdir() # Takes 1 second to execute cache(a = { Sys.sleep(1) "Hello World" }, .cachedir = tmp) # Executes instantly cache(a = { Sys.sleep(1) "Hello World" }, .cachedir = tmp) # Result is available in the current environment print(a) # Re-run the expression cache(a = { Sys.sleep(1) "Hello World" }, .cachedir = tmp, .rerun = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.