knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

The datacite class (see ?datacite()) is a modification of a data frame (tibble) object, and it creates all the mandatory and recommended fields of the DataCite metadata schema for a dataset. It also covers all the properties in the more general Dublin Core standard, but in some cases, the property name is different (and follows the DataCite naming convention.)

library(dataobservatory, quietly = TRUE)
data("datacite_properties")
datacite_properties

The datacite class is equipped with a construction and helper functions that create the more complex metadata properties as JSON (default) or list objects. Not all the helper functions are fully validated, but a fully datacite object can be easily obtained.

library(jsonlite, quietly = TRUE)
data("small_population")
small_population_dataset <- dataset (
  x= small_population,
  dataset_code = "small_population_total",
  dataset_title = "Population of Small European Countries",
  freq = "A",
  unit = "NR",
  unit_name = "number")

attributes (small_population_dataset)

The datacite_dataset() function fills out the datacite object with default properties. There are some properties where no default is given, these properties are also recorded in the dataset class as attributes.

small_population_datacite <- datacite_dataset(
  dataset = small_population_dataset,
  keywords = c("greendeal", "Demography", "Testing"),
  description = "Example dataset with three small countries",
  Subject = "Demography",
  Creator = "Joe, Doe")
small_population_dataset
small_population_datacite
is.datacite(small_population_datacite)

The Description property has three mandatory elements:

small_population_description <- small_population_datacite$Description
jsonlite::fromJSON(small_population_description)

Complex Properties

The Creator property may have affiliation data, and ORCiD identifier present, By default, we create a json representation:

jane <- add_creators("Jane", "Doe", 
                     affiliation = "Green Deal Data Observatory", 
                     orcid = "0000-0000-0000-0000")
jane

Working with lists

There are many Properties which can form a list. For example, there may be several related items present.

relitems <- add_related_items(
  RelatedItem = "Population on 1 January by age and sex", 
  relatedItemIdentifier = add_identifiers(
    id = "demo_pjan", 
    relatedItemType = "Dataset",
    relatedItemIdentifierType = "URL",
    URI = "https://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=demo_pjan/"
  ))

relitems
package_citation <- citation("dataobservatory")
relitems <- add_related_items(
  RelatedItem = package_citation$title, 
  relatedItemIdentifier = add_identifiers(
    id = "dataobservatory", 
    Version = package_citation$note),
    related_items = relitems
  )

relitems
print(small_population_datacite)
small_population_datacite$RelatedItem <- create_json_text(as.list(relitems))
small_population_datacite


dataobservatory-eu/dataobservatory documentation built on Jan. 7, 2022, 8:55 p.m.