This function returns an object that implements the methods list()
,
save()
, load()
, remove()
that list, store, load or
remove, respectively .rds or .RData files. The object is associated to a
folder that is given to this function.
Arguments
- path
path to the folder in which to store the RDS files. If the folder does not exist it is attempted to be created.
- type
one of
"rds"
,"RData"
, specifying the format used to store R objects.
Examples
# Create an empty test folder
path <- file.path(tempdir(), "test")
dir.create(path)
# Create a storage object pointing to a temporary test folder
storage <- kwb.utils::createStorage(path)
#> The directory "/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmpSdCvlf/test" already exists.
# At the beginning, the storage is empty
storage$list()
#> character(0)
# Store objects
apple <- 5
storage$save(apple, banana = list("Hello", "World"))
if (FALSE) {
# List the objects
storage$list()
# Retrieve an object
storage$load("banana")
# Remove objects
storage$remove("apple")
storage$remove("banana")
# The storage is empty again
storage$list()
}