dataset_download: Download data into a dataset

View source: R/dataset_download.R

dataset_downloadR Documentation

Download data into a dataset

Description

A wrapper around dataset and an import function.

Usage

dataset_download(
  Title,
  Dimensions = NULL,
  Measures = NULL,
  Attributes = NULL,
  Identifier = NULL,
  url,
  type = "csv",
  ...
)

dataset_download_csv(
  url,
  Title,
  Dimensions = NULL,
  Measures = NULL,
  Attributes = NULL,
  Identifier = NULL,
  type = "csv",
  destfile = NULL,
  method = "auto",
  quiet = TRUE,
  mode = "wb",
  cacheOK = TRUE
)

Arguments

Title

dct:title, a name given to the resource. datacite allows the use of alternate titles, too. See dataset_title.

Dimensions

The name or column number of the dimensions within the dataset.

Measures

The name or column number of the measures within the dataset.

Attributes

The name or column number of the attributes within the dataset.

Identifier

An unambiguous reference to the resource within a given context. Recommended practice is to identify the resource by means of a string conforming to an identification system. Examples include International Standard Book Number (ISBN), Digital Object Identifier (DOI), and Uniform Resource Name (URN). Select and identifier scheme from registered URI schemes maintained by IANA. More details: Guidelines for using resource identifiers in Dublin Core metadata and IEEE LOM. Similar to Identifier in datacite. See identifier.

url

a character string (or longer vector e.g., for the "libcurl" method) naming the URL of a resource to be downloaded.

type

A file type. Currently only csv is implemented that invokes utils::download.file.

...

allow additional arguments to be passed, unused.

destfile

a character string (or vector, see the url argument) with the file path where the downloaded file is to be saved. Tilde-expansion is performed.

method

Method to be used for downloading files. Current download methods are "internal", "wininet" (Windows only) "libcurl", "wget" and "curl", and there is a value "auto": see ‘Details’ and ‘Note’.

The method can also be set through the option "download.file.method": see options().

quiet

If TRUE, suppress status messages (if any), and the progress bar.

mode

character. The mode with which to write the file. Useful values are "w", "wb" (binary), "a" (append) and "ab". Not used for methods "wget" and "curl". See also ‘Details’, notably about using "wb" for Windows.

cacheOK

logical. Is a server-side cached value acceptable?

Value

A dataset with the downloaded dataset.

Examples


dest_file <- file.path(tempdir(), "iris.csv")
dataset_download(
  url = "https://zenodo.org/record/7421899/files/iris.csv?download=1",
  Dimensions = NULL,
  Measures = c("Sepal.Length", "Sepal.Width",  "Petal.Length", "Petal.Width" ),
  Attributes = "Species",
  Title = "Iris Dataset",
  Publisher = "American Iris Society",
  Identifier = "https://doi.org/10.1111/j.1469-1809.1936.tb02137.x",
  destfile = dest_file
)


dataset documentation built on March 31, 2023, 10:24 p.m.