Download external data for a module if not already present in the module directory, or if there is a checksum mismatch indicating that the file is not the correct one.

downloadData(module, path, quiet, quickCheck = FALSE,
  overwrite = FALSE, files = NULL, checked = NULL, urls = NULL,
  children = NULL, ...)

# S4 method for character,character,logical
downloadData(module, path, quiet,
  quickCheck = FALSE, overwrite = FALSE, files = NULL,
  checked = NULL, urls = NULL, children = NULL, ...)

# S4 method for character,missing,missing
downloadData(module, quickCheck,
  overwrite, files, checked, urls, children)

# S4 method for character,missing,logical
downloadData(module, quiet,
  quickCheck, overwrite, files, checked, urls, children)

# S4 method for character,character,missing
downloadData(module, path,
  quickCheck, overwrite, files, checked, urls, children)

Arguments

module

Character string giving the name of the module.

path

Character string giving the path to the module directory.

quiet

Logical. This is passed to download.file. Default is FALSE.

quickCheck

Logical. If TRUE, then the check with local data will only use file.size instead of digest::digest. This is faster, but potentially much less robust.

overwrite

Logical. Should local data files be overwritten in case they exist? Default is FALSE.

files

A character vector of length 1 or more if only a subset of files should be checked in the CHECKSUMS.txt file.

checked

The result of a previous checksums call. This should only be used when there is no possibility that the file has changed, i.e., if downloadData is called from inside another function.

urls

Character vector of urls from which to get the data. This is automatically found from module metadata when this function invoked with SpaDES.core::downloadModule(..., data = TRUE). See also prepInputs.

children

The character vector of child modules (without path) to also run downloadData on

...

Passed to preProcess, e.g., purge

Value

Invisibly, a list of downloaded files.

Details

downloadData requires a checksums file to work, as it will only download the files specified therein. Hence, module developers should make sure they have manually downloaded all the necessary data and ran checksums to build a checksums file.

There is an experimental attempt to use the googledrive package to download data from a shared (publically or with individual users) file. To try this, put the Google Drive URL in sourceURL argument of expectsInputs in the module metadata, and put the filename once downloaded in the objectName argument. If using Rstudio Server, you may need to use "out of band" authentication by setting options(httr_oob_default = TRUE). To avoid caching of Oauth credentials, set options(httr_oauth_cache = TRUE).

There is also an experimental option for the user to make a new CHECKSUMS.txt file if there is a sourceURL but no entry for that file. This is experimental and should be used with caution.

See also

prepInputs, checksums and downloadModule in SpaDES.core package for downloading modules and building a checksums file.

Examples

# NOT RUN {
# For a Google Drive example
# In metadata:
expectsInputs("theFilename.zip", "NA", "NA",
  sourceURL = "https://drive.google.com/open?id=1Ngb-jIRCSs1G6zcuaaCEFUwldbkI_K8Ez")
# create the checksums file
checksums("thisModule", "there", write = TRUE)
downloadData("thisModule", "there", files = "theFilename.zip")
# }