On 18 Jan 2006, [EMAIL PROTECTED] wrote:
> But, now suppose you want a slot to accept an object of class
> formula...
>> setClass("a",representation(b="list",c="formula"))
>> new("a",b=list(7)) Error in validObject(.Object) : invalid class
>> "a" object: invalid object
> for slot "c" in class "a": got class "NULL", should be or extend
> class "formula"
>
> Why can't new handle this? Why must the slot be defined?
Because 'formula' is not a formal S4 class. new("formula") doesn't
work.
And because isVirtualClass(getClass("formula")) returns TRUE, which I
find surprising since one can have an instance of a formula.
One workaround is to define a prototype:
setClass("a", representation(b="list", c="formula"),
prototype=prototype(c=formula(~1)))
+ seth
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html