ropensci / datapack

An R package to handle data packages
https://docs.ropensci.org/datapack
44 stars 9 forks source link

Error with setClassUnion when loading datapackage via devtools #23

Closed mbjones closed 9 years ago

mbjones commented 9 years ago

When trying to load datapackage using devtools::load_all(), I get an error now that seems to have an issue with creating a union class with setClassUnion. Related issues were reported, including hadley/devtools#657 and hadley/devtools#168. Code below illustrates the issue, and provides session info.

> library(devtools)
> load_all('.')
Loading datapackage
Error in .walkClassGraph(ClassDef, "contains", where, attr(ext, "conflicts")) : 
  the 'superClass' list for class “character”, includes an undefined class “EnumerationValue”
In addition: Warning message:
character(0) 
Error in setClassUnion("charOrNULL", c("character", "NULL")) (from DataPackage.R#176) : 
  unable to create union class:  could not set members "character"
> getwd()
[1] "/Users/jones/development/datapackage"
> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.3 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_1.8.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.6        roxygen2_4.1.1     XML_3.98-1.1       digest_0.6.8      
 [5] bitops_1.0-6       git2r_0.10.1       magrittr_1.5       stringi_0.4-1     
 [9] uuid_0.1-1         hash_2.2.6         tools_3.2.0        stringr_1.0.0     
[13] RCurl_1.95-4.6     rversions_1.0.0    memoise_0.2.1      redland_0.2.0.9000
mbjones commented 9 years ago

After looking a this issue, it seems to be an underlying issue with S4 classes handling union types containing a NULL. We don't really need the values to be NULL, as we can just use the standard default NA instead for missing params. So I will workaround using this approach.