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")
)

Arguments

tryToSave

The condition to check.

expression

The expression to execute.

objectName

The object to save the expression's result to.

path

The directory where to save or load the object (from).

prefix, suffix

A prefix or suffix to add in the filename.

filesToKeep

The number of files to keep.

silent

Whether to be chatty or silent.

object

The object to save or load.

Value

The object.