load_or_create: Load a file from a cache directory, or create and save it

Description Usage Arguments Value Examples

View source: R/helper-load_or_create.R

Description

Load a file from a cache directory, or create and save it

Usage

1
load_or_create(f, name, recreate = FALSE, cache_dir = "cache")

Arguments

f

function to call when the file does not exist.

name

name of cache file (including .rds).

recreate

if TRUE, recreate the file even if it exists.

cache_dir

directory that contains cache files. It is created if it does not exist.

Value

object created by function f, or stored in cache file

Examples

1
2
3
4
5
6
## Not run: 
 load_or_create(function() {
   rnorm(10000)
 }, "rnorm-results.rds", recreate=FALSE, cache_dir="cache")

## End(Not run)

fbreitwieser/pavian documentation built on Oct. 15, 2018, 11:06 a.m.