Skip to contents

Download one or all files in a Dataverse dataset.

Usage

download_dataverse_data(id, outdir = tempdir(), files = NULL,
  version = ":latest", server = NULL, key = NULL, load = TRUE,
  decompress = FALSE, refresh = FALSE, branch = NULL, verbose = FALSE)

download_dataverse_info(id, server = NULL, key = NULL, refresh = FALSE,
  branch = NULL, version = ":latest", verbose = FALSE)

Arguments

id

The dataset's persistent ID (e.g., "doi:10.18130/V3/SWK71R"), or a GitHub repository ("username/repo") with a R/sysdata.rda file containing a dataset_doi.

outdir

Directory in which to save files; defaults to a temporary directory.

files

Names (full or partial) of files to download, or a number or vector of numbers identifying file by index as listed on Dataverse; downloads all files in a dataset if not specified.

version

Version of the dataset to download. Specifying this will download all files, even if only a selection is requested.

server

Dataverse server; tries to get this from the DOI redirect, but falls back on Sys.getenv("DATAVERSE_SERVER"), then getOption("dataverse.server"), then "dataverse.lib.virginia.edu".

key

Dataverse API key; only needed if the requested dataset is not published. If not specified, looks for the key in Sys.getenv("DATAVERSE_KEY") and getOption("dataverse.key").

load

Logical; if FALSE, files will be downloaded but not loaded.

decompress

Logical; if TRUE, will attempt to decompress compressed files.

refresh

Logical; if TRUE, downloads and replaces any existing files.

branch

Name of the repository branch, if id is the name of a repository; uses the default branch if not specified.

verbose

Logical; if TRUE, prints status updates and warnings.

Value

download_dataverse_data: If load is TRUE, an invisible list with an entry for each data file if there are multiple files, or the loaded data file if a single file is requested. Tabular data files are loaded as data.tables. If load is FALSE, a list with the dataset's metadata.

download_dataverse_info: A list with the dataset's metadata.

Examples

if (FALSE) {
metadata <- download_dataverse_info("doi:10.18130/V3/SWK71R", verbose = TRUE)
data <- download_dataverse_data("doi:10.18130/V3/SWK71R", verbose = TRUE)
}