Learn R Programming

restatapi (version 0.6.0)

put_eurostat_cache: Put an object to cache

Description

Save the object (dataset/toc/DSD) to cache

Usage

put_eurostat_cache(obj, oname, update_cache = FALSE, cache_dir = NULL,
  compress_file = TRUE)

Arguments

obj

an object (toc, dataset, DSD)

oname

a character string with the name of the object to reference later in the cache

update_cache

a logical with a default value FALSE, whether to update the cache. In this case the existing value in the cache is overwritten. Can be set also with options(restatapi_update = TRUE)

cache_dir

a path to a cache directory. The default is NULL, in this case the object is saved in the memory (in the '.restatapi_env'). Otherwise if the cache_dir directory does not exist it saves in the 'restatapi' directory under the temporary directory from tempdir(). Directory can also be set with options(restatapi_cache_dir=...).

compress_file

a logical whether to compress the RDS-file in caching. Default is TRUE.

Value

The function returns the place where the object was cached: either it creates an the object in the memory ('.restatapi_env') or creates an RDS-file.

Details

Saves a given object in cache. This can be the memory .restatapi_env or on the hards disk. If the given cache_dir does not exist then the file is saved in the R temp directory (tempdir(). If the file or object with the oname exists in the cache, then the object is not cached.

Examples

Run this code
# NOT RUN {
dt<-data.frame(txt=c("a","b","c"),nr=c(1,2,3))
put_eurostat_cache(dt,"teszt")
get("teszt",envir=.restatapi_env)

# }

Run the code above in your browser using DataLab