View source: R/edit_attribute.R
edit_attribute | R Documentation |
This function edits the slots of a single attribute in an existing list of attributes for a data object.
edit_attribute(
attribute,
attributeName = NULL,
attributeLabel = NULL,
attributeDefinition = NULL,
domain = NULL,
measurementScale = NULL,
unit = NULL,
numberType = NULL,
definition = NULL,
formatString = NULL,
missingValueCode = NULL,
missingValueCodeExplanation = NULL
)
attribute |
(attribute) The attribute in the the attributeList of a data object. |
attributeName |
(character) The new name to give to the attribute. |
attributeLabel |
(character) The new label to give to the attribute. |
attributeDefinition |
(character) The new attributeDefinition to give to the attribute. |
domain |
(character) The new domain to give to the attribute. |
measurementScale |
(character) The new measurementScale to give to the attribute. |
unit |
(character) The new unit (for numericDomain) to give to the attribute. |
numberType |
(character) The new numberType (for numericDomain) to give to the attribute. |
definition |
(character) The new definition (for textDomain) to give to the attribute. |
formatString |
(character) The new formatString (for dateTime) to give to the attribute. |
missingValueCode |
(character) The new missing value code to give to the attribute. |
missingValueCodeExplanation |
(character) The new missing value code explanation to give to the attribute. |
This function can only be used on attributes entirely defined within the 'attributes' slot of attributeList; it cannot be used to edit the factors table of an enumeratedDomain.
In cases with very large attribute lists, use arcticdatautils::which_in_eml()
first to locate
the attribute index number in the attributeList.
(attribute) The modified attribute.
## Not run:
cn <- dataone::CNode('PROD')
mn <- dataone::getMNode(cn, 'urn:node:ARCTIC')
doc <- EML::read_eml(rawToChar(dataone::getObject(mn, "doi:10.18739/A23W02")))
new_attribute <- edit_attribute(doc$dataset$dataTable[[1]]$attributeList$attribute[[1]],
attributeName = "new name")
doc$dataset$dataTable[[1]]$attributeList$attribute[[1]] <- new_attribute
# Change an attribute's measurementScale from ratio to nominal
# (requires updating domain to textDomain or enumeratedDomain, setting unit and numberType
# to NA and adding a setting definition
new_attribute <- edit_attribute(doc$dataset$dataTable[[1]]$attributeList$attribute[[1]],
domain = "textDomain", measurementScale = "nominal", unit = NA,
numberType = NA, definition = 'new definition')
doc$dataset$dataTable[[1]]$attributeList$attribute[[1]] <- new_attribute
EML::eml_validate(doc) # validating complex EML changes is usually a good idea
# Add the same missing value codes to all attributes for a data object
new_attributes <- lapply(doc$dataset$dataTable[[1]]$attributeList$attribute, edit_attribute,
missingValueCode = "NA", missingValueCodeExplanation = "data unavailable")
doc$dataset$dataTable[[1]]$attributeList$attribute <- new_attributes
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.