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)

Arguments

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.

Value

(attribute) The modified attribute.

Details

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 which_in_eml() first to locate the attribute index number in the attributeList.

Examples

# NOT RUN {
# Change an attribute's name
new_attribute <- edit_attribute(eml@dataset@dataTable[[1]]@attributeList@attribute[[8]],
attributeName = "new name")
eml@dataset@dataTable[[1]]@attributeList@attribute[[8]] <- new_attribute

# Change an attribute's measurementScale from nominal to ratio
# (also requires changing domain, unit, and numberType as well
# as setting definition to NA)
new_attribute <- edit_attribute(eml@dataset@otherEntity[[2]]@attributeList@attribute[[1]],
domain = "numericDomain", measurementScale = "ratio", unit = "dimensionless",
numberType = "whole", definition = NA)
eml@dataset@otherEntity[[2]]@attributeList@attribute[[1]] <- new_attribute

# Add the same missing value codes to all attributes for a data object
new_attributes <- lapply(eml@dataset@dataTable[[1]]@attributeList@attribute, edit_attribute,
missingValueCode = "NA", missingValueCodeExplanation = "data unavailable")
eml@dataset@dataTable[[1]]@attributeList@attribute <- new_attributes
# }