zen4R

Build Status CRAN_Status_Badge Github_Status_Badge DOI

R Interface to Zenodo REST API

How to

require(devtools)
install_github("eblondel/zen4R")
require(zen4R)
zenodo <- ZenodoManager$new(token = <your_token>, logger = "DEBUG")
myrec <- zenodo$createEmptyRecord()
myrec$setTitle("My publication title")
myrec$setDescription("A description of my publication")
myrec$setUploadType("publication")
myrec$setPublicationType("article")
myrec$addCreator(firstname = "John", lastname = "Doe", affiliation = "Independent")
myrec$setLicense("mit")
myrec$addCommunity("ecfunded")
myrec$setKeywords(c("R","package","software"))
myrec <- zenodo$depositRecord(myrec)

There is no need to create an empty record with the function $createEmptyRecord() first on Zenodo and then fill it. You can create a record with ZenodoRecord$new(), fill it and then deposit it directly using the function $depositRecord(record).

In order to apply methods to upload a file or delete a record, you need to get the result of the function depositRecord (see example above) since after the deposition Zenodo returns the record that contains now an internal id required to identify and apply further actions. This id can be inspected with myrec$id.

Instead, if you don’t get the output of depositRecord and try to upload files or publish the record based on the the local record you handle (built upon ZenodoRecord$new()), this wil not work. Because it is a local record, the id of the record will still be NULL and Zenodo will be unable to identify which record on Zenodo needs to be handled.

zenodo$uploadFile("path_to_my_file", myrec$id) #upload a file
myrec_files <- zenodo$getFiles(myrec$id) #list files for the deposited record

Once the deposited record is fine for its publication online on Zenodo, you can publish it:

zenodo$publishRecord(myrec$id)

The method depositRecord handles a shortcut to publish directly the record specifying publish = TRUE (default is FALSE):

zenodo$depositRecord(myrec, publish = TRUE)

This shortcut is to use with cautious, as this will publish straight online your record on Zenodo.