The dataone R package enables R scripts to search, download and upload science data and metadata to the DataONE Federation. This package calls DataONE web services that allow client programs to interact with Member Nodes (MN) and DataONE Coordinating Nodes (CN).
See the full manual (help dataone
) for
documentation.
To search the DataONE Federation Member Node Knowledge Network for Biocomplexity (KNB) for a dataset:
library(dataone)
<- CNode("PROD")
cn <- getMNode(cn, "urn:node:KNB")
mn <- list(q="abstract:salmon+AND+keywords:acoustics+AND+keywords:\"Oncorhynchus nerka\"",
mySearchTerms fl="id,title,dateUploaded,abstract,size",
fq="dateUploaded:[2013-01-01T00:00:00.000Z TO 2014-01-01T00:00:00.000Z]",
sort="dateUploaded+desc")
<- query(mn, solrQuery=mySearchTerms, as="data.frame")
result 1,c("id", "title")]
result[<- result[1,'id'] pid
The metadata file located in the above search can be downloaded with the commands:
library(XML)
<- rawToChar(getObject(mn, pid)) metadata
The metadata file that describes the located research can be viewed in an XML viewer or text editor, once it is written to a disk file. This file details a data file (CSV) that can be obtained using the listed identifier, using the commands:
<- getObject(mn, "df35d.443.1")
dataRaw <- rawToChar(dataRaw)
dataChar <- textConnection(dataChar)
theData <- read.csv(theData, stringsAsFactors=FALSE)
df 1,] df[
Uploading a CSV file to a DataONE Member Node requires user
authentication. DataONE user authentication is described in the vignette
DataONE-Federation
.
Once the authentication steps have been followed, uploading is done with:
library(datapack)
library(uuid)
<- D1Client("STAGING", "urn:node:mnStageUCSB2")
d1c <- paste("urn:uuid:", UUIDgenerate(), sep="")
id <- data.frame(x=1:10,y=11:20)
testdf <- paste(tempfile(), ".csv", sep="")
csvfile write.csv(testdf, csvfile, row.names=FALSE)
# Build a DataObject containing the csv, and upload it to the Member Node
<- new("DataObject", id, format="text/csv", filename=csvfile) d1Object
uploadDataObject(d1c, d1Object, public=TRUE)
The dataone
R package vignettes can be viewed using the
R vignette
command, for example
vignette("dataone-overview")
.
The dataone
vignettes describe these topics:
Searching for data in DataONE described in vignette searching-dataone.
Downloading data from DataONE described in vignette download-data
Uploading data to DataONE is described in vignettes upload-data and update-package.
The DataONE Federation is described in the vignettes DataONE-Federation.
Work on this package was supported by:
Additional support was provided for working group collaboration by the National Center for Ecological Analysis and Synthesis, a Center funded by the University of California, Santa Barbara, and the State of California.