Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register classes with setOldClass #248

Closed
nuest opened this issue Mar 7, 2019 · 0 comments
Closed

Register classes with setOldClass #248

nuest opened this issue Mar 7, 2019 · 0 comments

Comments

@nuest
Copy link
Contributor

nuest commented Mar 7, 2019

Issue Description and Expected Result

It is not possible to use the class xml_document or xml_node in formal definitions of S4 classes.
It would be helpful for packages using S4 if they could properly define slots as being of a type provided by this package.

This should be possible with setOldClass.

(Let me know if you'd welcome a PR on this.)

Reproducible Example

library(xml2)

setClass("Testclass",
         representation(xml = "xml_document"),
         prototype = list(xml = xml2::xml_missing()),
         validity = function(object) {
           #...
           return(TRUE)
         }
)
Error in makePrototypeFromClassDef(properties, ClassDef, immediate, where) : 
  in making the prototype for class “Testclass” elements of the prototype failed to match the corresponding slot class: xml (class "xml_document" )
In addition: Warning message:
undefined slot classes in definition of "Testclass": xml(class "xml_document") 
Session Info
devtools::session_info()

─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.2 (2018-12-20)
 os       Ubuntu 18.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language en_GB:en                    
 collate  en_GB.UTF-8                 
 ctype    en_GB.UTF-8                 
 tz       Europe/Berlin               
 date     2019-03-07Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version    date       lib source        
 assertthat    0.2.0      2017-04-11 [1] CRAN (R 3.5.1)
 backports     1.1.3      2018-12-14 [1] CRAN (R 3.5.1)
 bitops      * 1.0-6      2013-08-17 [1] CRAN (R 3.5.1)
 callr         3.1.1      2018-12-21 [1] CRAN (R 3.5.1)
 cli           1.0.1      2018-09-25 [1] CRAN (R 3.5.1)
 crayon        1.3.4      2017-09-16 [1] CRAN (R 3.5.1)
 desc          1.2.0      2018-05-01 [1] CRAN (R 3.5.1)
 devtools      2.0.1      2018-10-26 [1] CRAN (R 3.5.1)
 digest        0.6.18     2018-10-10 [1] CRAN (R 3.5.1)
 fs            1.2.6      2018-08-23 [1] CRAN (R 3.5.1)
 glue          1.3.0      2018-07-17 [1] CRAN (R 3.5.1)
 httr        * 1.4.0      2018-12-11 [1] CRAN (R 3.5.2)
 lattice       0.20-38    2018-11-04 [1] CRAN (R 3.5.1)
 magrittr      1.5        2014-11-22 [1] CRAN (R 3.5.1)
 memoise       1.1.0      2017-04-21 [1] CRAN (R 3.5.1)
 pkgbuild      1.0.2      2018-10-16 [1] CRAN (R 3.5.1)
 pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.5.1)
 prettyunits   1.0.2      2015-07-13 [1] CRAN (R 3.5.1)
 processx      3.2.1      2018-12-05 [1] CRAN (R 3.5.1)
 ps            1.3.0      2018-12-21 [1] CRAN (R 3.5.1)
 R6            2.4.0      2019-02-14 [1] CRAN (R 3.5.2)
 Rcpp          1.0.0      2018-11-07 [1] CRAN (R 3.5.2)
 RCurl       * 1.95-4.11  2018-07-15 [1] CRAN (R 3.5.1)
 remotes       2.0.2      2018-10-30 [1] CRAN (R 3.5.1)
 rlang         0.3.1      2019-01-08 [1] CRAN (R 3.5.2)
 rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.5.1)
 rstudioapi    0.9.0      2019-01-09 [1] CRAN (R 3.5.2)
 sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.5.1)
 sos4R       * 0.3.0.9002 2019-03-07 [1] local         
 sp          * 1.3-1      2018-06-05 [1] CRAN (R 3.5.1)
 stringi       1.3.1      2019-02-13 [1] CRAN (R 3.5.2)
 stringr     * 1.4.0      2019-02-10 [1] CRAN (R 3.5.2)
 testthat    * 2.0.1      2018-10-13 [1] CRAN (R 3.5.1)
 usethis       1.4.0      2018-08-14 [1] CRAN (R 3.5.1)
 withr         2.1.2      2018-03-15 [1] CRAN (R 3.5.1)
 XML           3.98-1.17  2019-02-08 [1] CRAN (R 3.5.2)
 xml2        * 1.2.0      2018-01-24 [1] CRAN (R 3.5.1)
 yaml          2.2.0      2018-07-25 [1] CRAN (R 3.5.1)

[1] /home/daniel/R/x86_64-pc-linux-gnu-library/3.5
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant