S3 classes are treated as virtual classes, with or without a call to setOldClass()--the purpose of setOldClass() is to make method dispatch with S3 inheritance work.
It's legal to have virtual classes as slots, but yes, the slot is NULL in the prototype for the new class, unless the user specifies a value. In your case, providing a non-null prototype for the data.frame slot might be the desired solution. There is no S4 "initialization" for S3 classes; in fact, it's generally an error to use new() on them (or on other virtual classes). > getClass("data.frame") Virtual Class No Slots, prototype of class "NULL" Extends: "oldClass" Known Subclasses: "anova" > new("data.frame") Error in new("data.frame") : trying to use new() on a virtual class John PS: it's possible to imagine an extended version of setOldClass() that made S3 classes into non-virtual S4 classes. Worth discussion, but a definite change to current design. Matthias Kohl wrote: >you might need a call to "setOldClass"; see Section "Register or >Convert?" of the corresponding help page. > >Matthias > >Seth Falcon schrieb: > > > >>The default initialization for slots of class "factor" and >>"data.frame" gives NULL. This seems odd, since those slots can't ever >>be set to NULL by the user. I would expect zero-length instances of >>factor and data.frame. >> >>Here is an example: >> >>setClass("FOO", representation(a="factor", b="data.frame", c="numeric")) >>[1] "FOO" >> >> >> >> >>>ff <- new("FOO") >>>ff >>> >>> >>> >>> >>An object of class "FOO" >>Slot "a": >>NULL >> >>Slot "b": >>NULL >> >>Slot "c": >>numeric(0) >> >> >>sessionInfo() >>R version 2.3.0, 2005-12-26, powerpc-apple-darwin8.3.0 >> >>attached base packages: >>[1] "tools" "methods" "stats" "graphics" "grDevices" "utils" >>[7] "datasets" "base" >> >> >>Slot c is initialized as I was expecting. >> >>+ seth >> >>______________________________________________ >>R-devel@r-project.org mailing list >>https://stat.ethz.ch/mailman/listinfo/r-devel >> >> >> >> > > > > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel