On 04/22/2016 04:38 PM, Boylan, Ross wrote:
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.


A not too artificial solution is to create a base class, with derived classes corresponding to stateless or stateful conditions

Base = setClass("Base"); A = setClass("A", contains="Base"); A()

Martin Morgan

Thanks.
Ross Boylan

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



This email message may contain legally privileged and/or confidential 
information.  If you are not the intended recipient(s), or the employee or 
agent responsible for the delivery of this message to the intended 
recipient(s), you are hereby notified that any disclosure, copying, 
distribution, or use of this email message is prohibited.  If you have received 
this message in error, please notify the sender immediately by e-mail and 
delete this email message from your computer. Thank you.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to