Yes, this is possible by setting the class of a slot to be ANY
. For instance:
setClass('foo', slots = c(obj = 'ANY'))
Then the slot obj
in the class foo
can be used to store an object of any class.
Finally, the representation
parameter to setClass
was recently deprecated with version 3.0.0 of R, and you should use the slots
parameter (as above) instead.