Trying to define group methods for the "expression" class, running
into some problems.
> setMethod("Arith", signature(e1 = "expression", e2 =
"expression"),
+ function(e1, e2) 5)
[1] "Arith"
> expression(2)+expression(5)
Error in expression(2) + expression(5) : non-numeric argument to
binary operator
Is something sealed somewhere? If so, what was the effect of my
setMethod call, which gave no Error or Warning?
Here is what I am using as a workaround.
> setClass("Expression", representation("expression"))
[1] "Expression"
> setMethod("Arith", signature(e1 = "Expression", e2 =
"Expression"),
+ function(e1, e2) 5)
[1] "Arith"
> new("Expression", expression(2)) + new("Expression",
expression(5))
[1] 5
Is this the preferred workaround, or is there something better?
Franklin