reload_rmarkdown_cache: Reload Rmarkdown cache

reload_rmarkdown_cacheR Documentation

Reload Rmarkdown cache

Description

Reload Rmarkdown cache in the order files were created

Usage

reload_rmarkdown_cache(
  dir = ".",
  maxnum = 1000,
  max_cache_name = NULL,
  envir = globalenv(),
  file_sort = c("globals", "objects", "ctime", "mtime"),
  preferred_load_types = c("lazyLoad", "load"),
  dryrun = FALSE,
  verbose = TRUE,
  ...
)

Arguments

dir

character path to the directory that contains Rmarkdown cache files. Each file is recognized by the file extension ".rdx".

maxnum

integer indicating the maximum number of cache files to re-load, in order.

max_cache_name

character optional string indicating the name of an Rmarkdown cache chunk where this function will stop loading cache data. All cache files after this point will not be loaded. This option is intended to help recreate the data available to a particular Rmarkdown chunk during processing.

envir

environment where cache data will be loaded.

file_sort

character string indicating how to sort cache files to place them in proper order for re-loading. The default is to use one RMarkdown cache index file, which should accurately reflect only RMarkdown chunks present in the .Rmd file during rendering, and in the order they appear in that file. Using "mtime" or "ctime" below will sort files by the modification or creation time, respectively, and is less accurate, but often sufficient for most purposes. It would only be advised if for some reason the "__globals" or "__objects" files are not present.

  • "globals" uses the "__globals" file in the cache directory.

  • "objects" uses the "__objects" file in the cache directory.

  • ctime sorts by file creation time, default

  • mtime sorts by file modification time

preferred_load_types

character string indicating the preferred load mechanism to use. By default it will use lazyLoad() if .rdx/.rdb files are present, otherwise it falls back to using load() for .RData files. Remove "lazyLoad" to prevent lazy-loading of cached objects.

  • "lazyLoad" will try to use lazyLoad() to load .rdx/.rdb files

  • "load" will try to use load() to load .RData files

dryrun

logical indicating whether to perform a dry-run, which prints messages but does not process the data.

verbose

logical indicating whether to print verbose output. Note that this variable is not passed along to load(), since it is inconsistent with lazyLoad().

...

additional arguments are passed to lazyLoad() or load() as relevant to the method used to re-load the cache object data.

Details

This function is intended to help re-load Rmarkdown cache files created during the processing/rendering of an Rmarkdown file.

By default, all cached R objects are loaded into the global environment globalenv().

It can be given an argumen envir to store R objects inside a specific environment.

If supplied with max_cache_name then this function will only load the cache chunks in order, until it recognizes that chunk name. This option is intended to help restore the R data available for a particular Rmarkdown chunk.

Value

this function does not return data, but instead is called for the by-product of loading data into the given envir environment.

See Also

Other jam utility functions: call_fn_ellipsis()


jmw86069/jamba documentation built on Oct. 9, 2024, 10:52 a.m.