Read MR1 Data Packages from Zenodo
Source:R/readDataPackageFromZenodo.R
readDataPackageFromZenodo.RdreadDataPackageFromZenodo() downloads one or more MR1 data
packages from Zenodo and reads them as Frictionless
Data Packages, as created by createDataPackage(). Give the DOI of:
a data package (campaign). A version DOI reads that version; the concept DOI reads the latest version;
a collection (see
uploadCollectionToZenodo()): all its members are read, i.e. the latest version of each campaign of an owner collection, or of each campaign of each owner collection of the community collection.
The files are downloaded to outputDirPath, in one folder per Zenodo
record. Files that were already downloaded (same checksum) are not
downloaded again. Each package gets the property mr1dp:zenodo, with the
DOI, concept DOI, version and the collections (isPartOf) of its Zenodo
record. citeDataPackages() uses these to cite the data.
With several packages, merge = TRUE (default) merges them into one data
package with mergeDataPackages(); merge = FALSE returns a list of
separate packages.
Data files under embargo cannot be downloaded, except by the owner of the record (with their token). These records are skipped with a warning that shows the end of the embargo and the contact person(s) for data requests.
Arguments
- doi
Character vector with the DOIs (e.g.
"https://doi.org/10.5281/zenodo.1234567"or"10.5281/zenodo.1234567") or record IDs of the Zenodo records to read: data packages and/or collections.- outputDirPath
Directory to download the files to. Default is a folder
birdscanR_zenodoin the temporary directory of the R session; use a permanent directory to keep the files.- merge
logical. If
TRUE(default), several packages are merged into one withmergeDataPackages(). IfFALSE, a list of packages, named by campaign ID, is returned.- sandbox
logical. If
TRUE, read from the Zenodo sandbox (https://sandbox.zenodo.org). Default isFALSE.- token
Zenodo personal access token, only needed to download files of your own records under embargo. Default is the environment variable
ZENODO_TOKEN(orZENODO_SANDBOX_TOKENifsandbox = TRUE), if set. Public records are read without token.- overwrite
logical. If
TRUE, files are downloaded again even if they are already inoutputDirPath. Default isFALSE.
Value
One data package (class mr1dp and datapackage) if one package
is read or merge = TRUE; otherwise a named list of data packages. Read a
resource as a data frame with frictionless::read_resource().
See also
Other read file functions:
citeDataPackages(),
getManualVisibilityTable(),
mergeDataPackages()
Examples
if (FALSE) { # \dontrun{
# Read a data package from Zenodo
# ===========================================================================
dataPackage = readDataPackageFromZenodo(
doi = "https://doi.org/10.5281/zenodo.1234567",
outputDirPath = file.path(".", "zenodo")
)
echoData = frictionless::read_resource(dataPackage, "echo_data")
# Read all campaigns of a collection, as separate packages
# ===========================================================================
dataPackages = readDataPackageFromZenodo(
doi = "https://doi.org/10.5281/zenodo.7654321",
merge = FALSE
)
# Cite the data
# ===========================================================================
citeDataPackages(dataPackages)
} # }