Learn R Programming

xfun (version 0.48)

lazy_save: Save objects to files and lazy-load them

Description

The function lazy_save() saves objects to files with incremental integer names (e.g., the first object is saved to 1.rds, and the second object is saved to 2.rds, etc.). The function lazy_load() lazy-load objects from files saved via lazy_save(), i.e., a file will not be read until the object is used.

Usage

lazy_save(list = NULL, path = "./", method = "auto", envir = parent.frame())

lazy_load(path = "./", method = "auto", envir = parent.frame())

Value

lazy_save() returns invisible NULL; lazy_load() returns the object names invisibly.

Arguments

list

A character vector of object names. This list will be written to an index file with 0 as the base name (e.g., 0.rds).

path

The path to write files to / read files from.

method

The file save/load method. It can be a string (e.g., rds, raw, or qs) or a list. See the rw argument of cache_exec(). By default, it is automatically detected by checking the existence of the index file (e.g., 0.rds, 0.raw, or 0.qs).

envir

The environment to get or assign objects.

See Also