eml_set_reference: Set a reference to an EML object

View source: R/deprecated.R

eml_set_referenceR Documentation

Set a reference to an EML object

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("deprecated")}

Usage

eml_set_reference(element_to_reference, element_to_replace)

Arguments

element_to_reference

(list) An EML element to reference.

element_to_replace

(list) An EML element to replace with a reference.

Details

please add references directly instead

This function creates a new object with the same class as element_to_replace using a reference to element_to_reference.

Author(s)

Dominic Mullen dmullen17@gmail.com

Examples

## Not run: 
cn <- dataone::CNode('PROD')
adc <- dataone::getMNode(cn,'urn:node:ARCTIC')
doc <- EML::read_eml(dataone::getObject(adc, 'doi:10.18739/A2S17SS1M'))

# Set the first contact as a reference to the first creator
doc$dataset$contact[[1]] <- eml_set_reference(doc$dataset$creator[[1]],
doc$dataset$contact[[1]])

# This is also useful when we want to set references to a subset of 'dataTable'
  or 'otherEntity' objects
# Add a few more objects first to illustrate the use:
doc$dataset$dataTable[[3]] <- doc$dataset$dataTable[[1]]
doc$dataset$dataTable[[4]] <- doc$dataset$dataTable[[1]]
# Add references to the second and third elements only (not the 4th):
for (i in 2:3) {
    doc$dataset$dataTable[[i]]$attributeList <- eml_set_reference(
                                                      doc$dataset$dataTable[[1]]$attributeList,
                                                      doc$dataset$dataTable[[i]]$attributeList)
}
# If we print the entire 'dataTable' list we see elements 2 and 3 have
references while 4 does not.

doc$dataset$dataTable

## End(Not run)

NCEAS/arcticdatautils documentation built on Aug. 28, 2023, 12:10 p.m.