Is it possible to declare a variable btw. representation like "obj" of a arbitrary type, that means an ancestor, where all data types derived from? So that I can appropriate each type to representation type? Should I put this flexible parameter into a list?
setClass(Class = "MyClass",
representation = representation(obj = "object"
)
)
new("MyClassA",name="abc",typ=123)
Yes, this is possible by setting the class of a slot to be
ANY. For instance:Then the slot
objin the classfoocan be used to store an object of any class.Finally, the
representationparameter tosetClasswas recently deprecated with version 3.0.0 of R, and you should use theslotsparameter (as above) instead.