Open jeanetteclark opened 4 years ago
I realized today that this is an error on my part - get_attributes
needs to be run on an attributeList
not the entity.
hmm, I wonder if we could a some type-checking step to get_attributes()
so that it throws a more helpful error message at least...
Reopening, as this unboxing issue does seem to occur, provided that the eml is read from a file and not simply generated in code. Modifying @jeanetteclark's MRE to write and then read the simple EML before calling get_attributes yields an error when only one attribute is present.
me <- list(individualName = list(givenName = "Brunjes", surName = "Ian"))
attributes <- data.frame(attributeName = 'length_1',
attributeDefinition = 'def1',
measurementScale = 'ratio',
domain = 'numericDomain',
unit = 'meter',
numberType = 'real',
stringsAsFactors = FALSE)
att_list <- set_attributes(attributes)
doc_ex <- list(packageId = "id", system = "system",
dataset = list(title = "A Mimimal Valid EML Dataset",
creator = me,
contact = me,
dataTable = list(entityName = "data table", attributeList = att_list))
)
write_eml(doc_ex, "tempfile.xml")
eml_from_file <- read_eml("tempfile.xml")
file.remove("tempfile.xml")
get_attributes(eml_from_file$dataset$dataTable$attributeList)
# Error: $ operator is invalid for atomic vectors
Pretty sure this is because of the unboxing issue. I'll try to put in a fix for this when I can, but if anyone else wants to have at it, here is a reprex