I would like to define an S4 class in R. One of the slots should contain an mcmc
object as defined in the coda
package. I tried the following:
library("coda")
setClass(Class = "myClass", representation = representation(var = "mcmc"))
But this results in a warning:
Undefined slot classes in the definition of "myClass": var(class "mcmc")
The class definition does not work later on and throws an error message because var
has an "undefined class".
How can I tell the setClass
command where to look for the definition of mcmc
objects?
I believe this is because mcmc
is an S3 class and not a formal S4
class. You would need to use setOldClass
to register the S3
as a formally defined class.
setOldClass("mcmc")
setClass(Class = "myClass", representation = representation(var = "mcmc"))