zen_file {zendown} | R Documentation |
Access a Zenodo deposit file
Description
Get the local path to a Zenodo deposit file. It not cached in a mirror yet, it will download the file to a deposit mirror cache locally.
Usage
zen_file(
deposit_id,
file_name,
cache_type = NULL,
cache_dir = NULL,
clear_cache = FALSE,
quiet = FALSE
)
Arguments
deposit_id |
numeric. The Zenodo deposit id. |
file_name |
character. If |
cache_type |
character. Use |
cache_dir |
character. User specified cache directory for persistent cache type. |
clear_cache |
logical. If the mirror already exists, clear its content. |
quiet |
logical. Show download info and progress bar. |
Value
a string with the mirror file path.
Cache type
The Zenodo mirror will be cached locally on a system folder. This folder can be temporary, being cleared when the R session is ended, or persistent across sections and reboots.
If the cache_type
argument is NULL
(the default) the package will check first the environment variable zendown_cache_type
. If set, the package will use its value. If not set, a temporary cache folder will be used as default.
You can set an environment variable with usethis::edit_r_environ()
and write as bellow for a persistent cache storage.
zendown_cache_type = "persistent"
After saving the file, remember to restart the session. With this setting, the cache will be persistent and stored at the directory given by tools::R_user_dir("zendown", which = "cache")
You may also use a different folder for persistent storage by setting the zendown_cache_dir
environment variable. For example:
zendown_cache_dir = C:\my_cache\
If you set the cache_type
argument directly as temporary
or persistent
, it will override the environment setting.
Examples
# https://zenodo.org/records/10959197
zen_file_path <- zen_file(10959197, "iris.rds")
print(zen_file_path)
file.exists(zen_file_path)