Create a new data package
adapted from the dataone and datapack vingettes
Create a new data package
- a data package is a class that has slots for relations (provenance), objects(the metadata and data file(s)) and systemMetadata.
Upload new data files
Create and add a metadata file to the data package
In this example we will use this previously written EML metadata. Here, we are getting the file path from the dataone package and saving that as the object emlFile.
This is a bit of an unusual way to reference a local file path, but all this does is it looks within the R package dataone and it grabs the path to a metadata document stored within that package. If you print the value of emlFile you’ll see it is just a file path, but it points to a special place on the server where that package is installed. Usually you will just reference EML paths that are stored within your user file system.
Create a new DataObject for the metadata and add it to the package.
metadataObj <- new("DataObject", format="https://eml.ecoinformatics.org/eml-2.2.0", filename=emlFile)
dp <- addMember(dp, metadataObj)Here, we have to specify the format of the metadata file. In this case, we are using EML version 2.2.0, so we specify that as the format. Different format IDs can be browsed through this DataONE reference list. The addMember() function adds the metadata object to the data package and also creates a unique identifier for it.
Check the dp object to see if the metadata object was added correctly.
Add some additional data files
sourceData <- system.file("extdata/OwlNightj.csv", package="dataone")
sourceObj <- new("DataObject", format="text/csv", filename=sourceData)
dp <- addMember(dp, sourceObj, metadataObj) # The third argument of addMember() associates the new DataObject to the metadata that was just added.
If you want to change the formatId please use
updateSystemMetadata (more on this later in the book)