dc: dc: A Package to download and cache data files from the web

Description Usage Arguments Value

View source: R/dc.R

Description

General function for downloading and caching a dataset. This is called by e.g. dc.argo() and the other functions in the dc package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dc(
  url = NULL,
  destdir = ".",
  destfile = NULL,
  mode = "wb",
  quiet = FALSE,
  force = FALSE,
  dryrun = FALSE,
  ntrials = 3,
  debug = getOption("dcDebug", 0)
)

Arguments

url

character value giving the full URL of a file to be downloaded. This is constructed by specialized functions, e.g. dc.argo() computes this from its server and other arguments, based on reverse engineering the URLs of Argo files provided by a particular server.

destdir

character value indicating the directory in which to store downloaded files. The default value of "." means to store the downloaded file in the present working directory. Set destdir=NULL if destfile is a filename with full path information. File clutter is reduced by creating a top-level directory called data, with subdirectories for various file types; see “Examples”.

destfile

character value indicating the name of the file. If not supplied, then the file name is constructed from the other parameters of the function call, so that subsequent calls with the same parameters will yield the same result; this is useful for caching.

mode

character value passed to curl::curl_download(), controlling the mode used in writing the local file. The default value, mode="wb", means to set the write format to binary. This is necessary on Windows machines, which otherwise will alter newline characters, ruining file integrity for binary files (such as netcdf files). The setting is not required on other machines, but it makes sense to use this default in all instances. See the documentation for curl::curl_download().

quiet

logical value, passed to curl::curl_download(), that indicates whether to download silently. Since some downloads can be slow, the default value is quiet=FALSE.

force

A logical value that indicates whether to force the download, even if the pathname constructed from destdir and destfile already exists.

dryrun

A logical value that indicates whether to return the constructed web query, without attempting to download the file. This can be helpful in designing responses to changing URLs.

ntrials

integer controlling the number of times to attempt to download the file. The default value, ntrials=3, indicates to try a second time if the first one fails, and a third time if the second one fails, but to stop with an error, if all three fail.

debug

an integer specifying whether debugging information is to be printed during processing. The printing is done by a call to dcDebug(). Setting debug=0 turns off this form of debugging, while higher values yield more information. If one dc function calls another, it passes the value of debug but decreased by 1, which means that the value of debug controls not just the breadth of debugging, but also the depth.

Value

String indicating the full pathname to the downloaded file.


dankelley/dc documentation built on June 3, 2020, 8:25 a.m.