ropensci / EML

Ecological Metadata Language interface for R: synthesis and integration of heterogenous data
https://docs.ropensci.org/EML
Other
98 stars 33 forks source link

eml_get should throw error/warning for non-existent elements #273

Open atn38 opened 5 years ago

atn38 commented 5 years ago

Nothing happens if I try to do this

library(EML)

person <- list(individualName = list(givenName = "Blizzard", surName = "Frosty"))

my_eml <- list(packageId = "id", system = "system",
               dataset = list(
                 title = "A Mimimally Valid EML Doc",
                 creator = person,
                 contact = person
))

publisher <- eml_get(my_eml$dataset, element = "publisher")

Returned publisher is a list of one @context.

This isn't too much of a problem, since if this is next

my_eml$dataset$publisher <- publisher

Resulting EML is still valid and serialized .xml doesn't contain <publisher> element. But it'd be more informative if eml_get says something for non-existent elements.

jeanetteclark commented 5 years ago

I'm not sure that I agree - your example returns an empty emld list since there are no matches. This is similar to the behavior of many other R functions that also do not have such warnings, such as filter in the example below:

library(tidyverse)

df <- tribble(
  ~colA, ~colB,
  "a",   1,
  "b",   2,
)

result <- df %>% 
  filter(colA == "e")

Happy to hear other perspectives!