Hi all,
I am having a little problem with S4 group generics (apologies if I
get some terminology wrong below). I'm finding I can set methods for some
group generic functions, but not others:
> setClass("foo", representation(data="numeric"))
> x <- new("foo", data=1:10)
## Setting "Ops" works just as expected:> setMethod("Ops", signature("foo", "foo"),
function(e1, e2)
match.fun(.Generic)(e1@data, e2@data))> x+x
[1] 2 4 6 8 10 12 14 16 18 20
## But "Summary" does not:> setMethod("Summary", signature("foo"), function(x, ...,
na.rm=FALSE)
browser())> min(x)
[1] Inf
Warning message:
no finite arguments to min; returning Inf
## However, getMethod() shows that the method is
registered:> getMethod("Summary", "foo")
Method Definition:
function (x, ..., na.rm = FALSE)
.Generic(x@data, ..., na.rm = na.rm)
Signatures:
x
target "foo"
defined "foo"
If I set a method directly for the members of "Summary" (e.g. min),
the new function is still not dispatched.
Of the group generics listed in ?Summary, Arith, Compare, Ops, and
Complex work for me, and I cannot get Math, Math2 or Summary to work.
I presume I'm probably missing something, but am at a loss. I would
appreciate any pointers as to what I am doing wrong. I have run into
this problem on both Linux/R 2.0.1, and Windows/R 2.0.0 (will upgrade
soon!).
Thanks,
Rich
--
Rich FitzJohn
rich.fitzjohn <at> gmail.com |
http://homepages.paradise.net.nz/richa183
You are in a maze of twisty little functions, all alike
--
Rich FitzJohn
rich.fitzjohn <at> gmail.com |
http://homepages.paradise.net.nz/richa183
You are in a maze of twisty little functions, all alike