something_akin_to_caching.Rd
These functions try to facilitate working with large objects.
save_or_load_rds
and save_or_load_csv
check whether an object exists;
if it does and tryToSave
is TRUE, it saves
it using a system where the number of backups is limited (to 2 files
by default), so automatically deleting the oldest version; and f it does
not exist, it loads one of the automatically saved versions. This
functionality can be useful when working with large scripts that
take a lot of time to create or process objects.
create_and_save_or_load_rds
checks tryToSave
; if it's TRUE
, it
executes the expression and saves the result; otherwise, it tries to load
the file from disk.
create_and_save_or_load_rds(
tryToSave,
expression,
objectName,
path,
prefix = "autogenerated",
suffix = "",
filesToKeep = 2,
silent = metabefor::opts$get("silent")
)
save_or_load_csv(
object,
path,
tryToSave = TRUE,
prefix = "autogenerated",
suffix = "",
filesToKeep = 2,
silent = metabefor::opts$get("silent")
)
save_or_load_rds(
object,
path,
tryToSave = TRUE,
prefix = "autogenerated",
suffix = "",
filesToKeep = 2,
silent = metabefor::opts$get("silent")
)
The condition to check.
The expression to execute.
The object to save the expression's result to.
The directory where to save or load the object (from).
A prefix or suffix to add in the filename.
The number of files to keep.
Whether to be chatty or silent.
The object to save or load.
The object.