datapack Background

adapted from the dataone and datapack vignettes

datapack is written differently than most R packages you may have encountered in the past. This is because it uses the S4 system instead.

library(dataone)
library(datapack)
library(uuid)

Data packages

Data packages are a class that has slots for relations (provenance), objects(the metadata and data file(s)) and systemMetadata.

Data Objects

You can see what slots are in an S4 object after typing the subsetting operator @, or pressing TAB with the cursor after an existing @. Try viewing the slots of the data package.

dp@

Check out the objects slot

dp@objects

The objects slot contains a list of object PIDs that are accessed using the $ subsetting operator. Both are found within the structure of data packages in R.

Get the number for data and metadata files associated with this data package:

getSize(dp)

Get the file names and corresponding pids

getValue(dp, name="sysmeta@fileName")

Get identifiers

You can search by any of the sysmeta slots such as fileName and formatId and get the corresponding identifier(s):

metadataId <- selectMember(dp, name="sysmeta@ADD THE NAME OF THE SLOT", value="PATTERN TO SEARCH BY")

Example:

selectMember(dp, name="sysmeta@formatId", value="image/tiff") 
selectMember(dp, name="sysmeta@fileName", value="filename.csv")

Provenance

View the provenance as a dataTable. We will get into detail in the Building provenance chapter.

dp@relations$relations