get_from_zenodo()
allows you to easy download a Zenodo record or
a Zenodo file.
This function only works for Zenodo created DOIs (not when the DOI is, for example, derived from Zookeys).
get_from_zenodo(doi, path = ".", file = NULL, parallel = FALSE)
A string indicating a Zenodo DOI (Digital Object Identifier)
starting with "10.5281/zenodo."
. See the Examples section to learn more.
(optional) a string indicating a directory path where the data
must be downloaded (default: "."
).
(optional) a character
object with the
names of the files that must be downloaded. If NULL
, the function will
download the entire record (default: NULL
).
(optional) a logical
value indicating if
the function must run a number of parallel processes, each downloading
another file (requires the parallel
package). This is useful when multiple large files are present in the
Zenodo record, which otherwise would be downloaded sequentially. Of course,
the operation is limited by bandwidth and traffic limitations (default:
FALSE
).
A character
object with the paths for all the files
downloaded.
This function requires an internet connection and the
curl
,
jsonlite
,
parallel
, and
tools
packages to work.
If you don't have any or one of the packages mentioned above, you can install
them with install.packages("curl", "jsonlite", "parallel", "tools")
.
You can find more about the Zenodo API at https://developers.zenodo.org/.
get_from_zenodo()
code is based on the download_zenodo()
function found
in the inborutils
package of the
Research Institute for Nature and Forest (INBO).
download_zenodo()
was created by Hans Van Calster (hans.vancalster@inbo.be)
and Floris Vanderhaeghe (floris.vanderhaeghe@inbo.be).
We give our thanks for the INBO institute and for all developers involved in this piece of software.
Please note that this code comes with an MIT License. You can read the latter below.
Copyright (c) 2016 Instituut voor Natuur en Bosonderzoek (INBO)
Permission is hereby granted, free of charge, to any person obtaining a copyfiles (the "Software"), to deal
of this software and associated documentation in the Software without restriction, including without limitation the rights
/or sell
to use, copy, modify, merge, publish, distribute, sublicense, and
copies of the Software, and to permit persons to whom the Software is:
furnished to do so, subject to the following conditions
in
The above copyright notice and this permission notice shall be included
all copies or substantial portions of the Software.
"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
THE SOFTWARE IS PROVIDED
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Other API functions:
get_sun_stats()
if (FALSE) {
## Downloading a single file from a Zenodo record
path <- tempdir()
file <- "sleep-diary.txt"
get_from_zenodo(
doi = "10.5281/zenodo.4898822", path = path, file = file
)
readLines(file.path(path, file))
## Downloading all the files from a Zenodo record
get_from_zenodo(
doi = "10.5281/zenodo.4898822", path = tempdir(), file = NULL
)
## Downloading all the files from a Zenodo record using parallel
## computation
get_from_zenodo(
doi = "10.5281/zenodo.4898822", path = tempdir(), file = NULL,
parallel = TRUE
)
}