Learn R Programming

SpaDES.core (version 2.0.5)

downloadData: Download module data

Description

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.

Usage

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 )

Value

Invisibly, a list of downloaded files.

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 reproducible::preProcess(), e.g., purge

Author

Alex Chubaty & Eliot McIntire

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 (publicly 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() for downloading modules and building a checksums file.

Examples

Run this code
# \donttest{
# In metadata, each expectsInput has a sourceURL; downloadData will look for
# that and download if it defined; however this sample module has all
# NAs for sourceURL, so nothing to download
modulePath <- getSampleModules(tempdir())
downloadData("caribouMovement", path = modulePath)
# }

Run the code above in your browser using DataLab