Skip to contents

It supports Nextcloud public links in case of using cloud. In this case, this function can download the file in a temporary folder and returns the path of the downloaded file. This functionality is useful for read_excel from the package readxl (See: https://stackoverflow.com/a/41368947/5300212).

Usage

getDataPath(
  path,
  ...,
  use_cache = TRUE,
  cfg = loadConfig(),
  root = cfg$data$path,
  cache = Sys.getenv("PKG_DATA_CACHE", file.path(dirname(tempdir()), packageName()))
)

Arguments

path

character representing the path of the data in the database

...

character path elements to add after path

use_cache

logical download the data and use cache location

cfg

a config object. Configuration to use. See loadConfig for details

root

character URL or path of the database root

cache

character path where downloaded files from cloud are cached (See details)

Value

character with the path of the file to read either on:

  • the local storage if cfg$data$cloud == FALSE

  • the cache directory if cfg$data$cloud == FALSE and use_cache == TRUE

  • the cloud server if cfg$data$cloud == FALSE and use_cache == FALSE

Details

The cache directory is by default located in the system temporary folder in a subdirectory named as the package name or the value of the environment variable "PKG_DATA_CACHE" if it is defined.