Downloaded archives are stored in a local cache so that a reference month is never downloaded twice. The location is resolved in this order:
Details
the
cache_dirargument;the
CAGEDR_CACHE_DIRenvironment variable;the
cagedr.cache_dirR option;a session-scoped folder under
tempdir(), which R removes when the session ends.
Set one of the first three to keep the archives between sessions. Files published by the Ministry are large (about 55 MB per month) and change only when a month is re-published, so a persistent cache is recommended for repeated work.
Examples
caged_cache_dir()
#> [1] "/tmp/RtmpXQqrCb/cagedr-cache"
# For a persistent cache, set the environment variable (for instance in
# your .Renviron). Here a temporary folder is used and the previous value
# is restored afterwards.
old <- Sys.getenv("CAGEDR_CACHE_DIR", unset = NA)
Sys.setenv(CAGEDR_CACHE_DIR = file.path(tempdir(), "caged-cache"))
caged_cache_dir()
#> [1] "/tmp/RtmpXQqrCb/caged-cache"
if (is.na(old)) Sys.unsetenv("CAGEDR_CACHE_DIR") else Sys.setenv(CAGEDR_CACHE_DIR = old)