[R] field of two possible types in reference classes
Martin Ivanov
tramni at abv.bg
Mon Mar 24 13:44:26 CET 2014
Dear R users,
I am learning the OOP programming with R, in particular with reference classes.
If I have a class, e.g.
myclass <- setRefClass(class="myclass", fields=list(x="numeric"));
I know that if I do not want to set any class for x, I can just type fields=list(x="ANY"). But what if
I want to allow x to be of two possible classes, e.g. "numeric" or "logical". They do not inherit from each other, so setting the one and passing the other class results in an error.
Any suggestions will be appreciated.
Best regards,
Martin
More information about the R-help
mailing list