In order to build a generic framework i would like to build an s4 class with a slot that could be of any type. Is it possible? And if so how?
I have found this question that adress the multiple types problem. But I would like to make it possible for any types not just some predefined types.
setClass("foo",
representation(
anything = "..."
)
)
# I would like to be able to perform all of these
new("foo", anything = 1)
new("foo", anything = "a")
new("foo", anything = data.frame())
...
Yes, you could do something like:
setClass("hi", slots = c(slot1 = "ANY"))
The use of ANY
is actually documented in the help.