sorry, please replace exportClass by exportClasses > Hello, > > I have a question concerning "setClassUnion". > I'm working with R 2.0.0 Patched (2004-10-06) on windows 2000. > > I tried to use "setClassUnion" in a package I am currently working on. > The situation is similar to the following example: > > The DESCRIPTION file has entries: > Depends: R (>= 2.0.0), methods > Imports: methods > LazyLoad: yes > > The NAMESPACE file has entries: > importClassesFrom("methods", "NULL", "numeric") > exportClass("OptionalNumeric", "class1", "class2")
exportClasses("OptionalNumeric", "class1", "class2") > > The example R code is: > .onLoad <- function(lib, pkg){ > require("methods", character = TRUE, quietly = TRUE) > } > > setClassUnion("OptionalNumeric", c("numeric", "NULL")) > > setClass("class1", > representation(test1 = "OptionalNumeric"), > prototype(test1 = numeric(1))) > > # why does this not work? > # The error I get is: > # Error in makePrototypeFromClassDef(properties, ClassDef, immediate, # > where) :In making the prototype for class "class1" elements of the # > prototype failed to match the corresponding slot class: test1 > # (class "OptionalNumeric ") > # Sourcing this into R gives no error for me > > # but instead using > prototype(test1 = NULL) > # works > > # Moreover, using the second version (with test1 = NULL) > # the following works, too > setClass("class2", > representation(test2 = "class1"), > prototype(test2 = new("class1", test1 = numeric(1)))) > > What am I doing wrong? > Can someone please explain this to me? > > Thanks for your help, > Matthias > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html