[R] S4 non-virtual class with no slots?
Boylan, Ross
Ross.Boylan at ucsf.edu
Fri Apr 22 22:38:57 CEST 2016
It seems that if an S4 class has no slots it can't be instantiated because it is assumed to be virtual. Is there a way around this other than adding a do-nothing slot? A singleton would be OK, though is not essential.
Problem:
EmptyFitResult <- setClass("EmptyFitResult", representation=representation())
# also tried it without the second argument. same result.
> e <- EmptyFitResult()
Error in new("EmptyFitResult", ...) :
trying to generate an object from a virtual class ("EmptyFitResult")
This in R 3.1.1.
Context:
I fit simulated data; in some simulations none survive to the second stage of fitting. So I just need a way to record that this happened, in a way that integrates with my other non-null results.
Thanks.
Ross Boylan
More information about the R-help
mailing list