Skip to contents

This function allows the user to set a cache location for Stan models rather than a temporary directory. This can reduce the need for model compilation on every new model run across sessions or within a session. For R version 4.0.0 and above, it's recommended to use the persistent cache as shown in the example.

Usage

enw_set_cache(path, type = c("session", "persistent", "all"))

Arguments

path

A valid filepath representing the desired cache location. If the directory does not exist it will be created.

type

A character string specifying the cache type. It can be one of "session", "persistent", or "all". Default is "session". "session" sets the cache for the current session, "persistent" writes the cache location to the user’s .Renviron file, and "all" does both.

Value

The string of the filepath set.

See also

Examples

if (FALSE) { # interactive()
# Set to local directory
my_enw_cache <- enw_set_cache(file.path(tempdir(), "test"))
enw_get_cache()
if (FALSE) {
# Use the package cache in R >= 4.0
if (R.version.string >= "4.0.0") {
 enw_set_cache(
   tools::R_user_dir(package = "epinowcast", "cache"), type = "all"
 )
}

}
}