Skip to contents

Downloaded archive files, boundaries and lookups are cached on disk so that each is fetched once. By default the cache is a directory inside the session's temporary directory: it is deleted when R closes, and nothing is written to your file space.

Usage

lamp_cache_dir(create = TRUE)

lamp_cache_clear(subdir = NULL)

Arguments

create

Create the directory if it does not exist? Default TRUE.

subdir

Optional sub-directory to clear instead of the whole cache, for example "archive".

Value

The cache directory path, invisibly for lamp_cache_clear().

Details

To keep downloads between sessions, which is worth doing before building a national panel of several gigabytes, choose a directory and set it with the option streetlamp.cache_dir or the environment variable STREETLAMP_CACHE_DIR (the option wins). The conventional place is the user cache directory, for example in .Rprofile:

options(streetlamp.cache_dir = tools::R_user_dir("streetlamp", "cache"))

lamp_cache_clear() deletes the cache, or one sub-directory of it.

Examples

# Point the cache at a temporary directory for the duration of the example
old <- options(streetlamp.cache_dir = tempfile("streetlamp-cache-"))
lamp_cache_dir()
#> [1] "/tmp/RtmpUEgbc3/streetlamp-cache-1e8224a58d9"
lamp_cache_clear()
#> Cleared 0 files from /tmp/RtmpUEgbc3/streetlamp-cache-1e8224a58d9.
options(old)