Skip to contents

Creates a directory for the dataset and downloads all of its files. Returns (invisibly) a data frame with file info.

Usage

dataverse_file_download(
  host,
  doi,
  download_to,
  max_file_size = 10,
  max_download_size = 100,
  unzip_types = NULL,
  pb = NULL
)

Arguments

host

the Dataverse installation's hostname (e.g. "dataverse.harvard.edu")

doi

the dataset's persistentId (a DOI, e.g. "10.7910/DVN/GGDUND")

download_to

path to download to; there is no default, because CRAN does not allow writing into the working directory unless you ask for it

max_file_size

maximum file size to download (in MB) - set to NULL or Inf for no restrictions

max_download_size

maximum total size to download - set to NULL or Inf for no restrictions

unzip_types

file categories to extract from .zip files in the dataset rather than downloading the zip whole, named as data_classify_files() names them: "data", "code", "materials", "documentation", "output", "unknown". More than one may be given. NULL (the default) downloads zips whole and leaves them zipped, as before. max_file_size applies to each extracted member rather than to the archive.

pb

a progress bar passed from another function

Value

data frame of file info. When members are extracted from a zip, its row reports the zip with extracted giving the number of members written; size_on_disk and checksum_ok are then NA, because what is on disk is the members rather than the archive Dataverse published a size and MD5 for.

Details

You can limit downloads to only files under a specific size (defaults to 10MB) and only a maximum download size (largest files will be omitted until total size is under the limit). Omitted files will be listed as messages in verbose mode, and included in the returned data frame with the downloaded column value set to FALSE.

A .zip in the dataset is normally fetched whole and left as a zip. Set unzip_types to pull only the files you want out of it instead: Dataverse's file-download endpoint honours byte-range requests (verified 2026-08-14 against demo.dataverse.org: HEAD/Range both return Accept-Ranges: bytes and a 206 Partial Content response) and each member of a zip is compressed separately, so the wanted members can be read out of the archive while the rest is never transferred – the same mechanism zenodo_file_download() uses. When the archive cannot be read that way, it is downloaded whole as before, so this never loses a file – it only avoids transferring one.

Examples

# \donttest{
if (online("dataverse.harvard.edu")) {
  dl <- dataverse_file_download("dataverse.harvard.edu", "10.7910/DVN/GGDUND",
                                download_to = file.path(tempdir(), "dataverse"),
                                max_download_size = 10)
}
# }