Dear UseRs,
Setting methods for groups ("compare" in this case) does not work
properly. Once one method is set ,redefining it or even removing does not
change the behavior:
setClass("foo"
,representation(range="numeric")
)
#[1] "foo"
setMethod("Compare",c(e1="ANY",e2="foo"),
function(e1,e2){
browser()
callGeneric(e1,e...@range)
})
#[1] "Compare"
o<-new("foo",range=c(1,2))
2>o
#Called from: 2 > o
#Browse[1]>
#[1] TRUE FALSE ##Enters browser as expected !!!
# Now, remove browser()
setMethod("Compare",c(e1="ANY",e2="foo"),
function(e1,e2){
callGeneric(e1,e...@range)
})
2>o
#Called from: 2 > o
#Browse[1]> ######## Oups, the old function is executed here?????????
########
#[1] TRUE FALSE
selectMethod(">=",c(class(2),class(o)),optional=T) ### Shows real
method!!!!!
#function (e1, e2)
#{
# callGeneric(e1, e...@range)
#}
#
#Signatures:
# e1 e2
#target "numeric" "foo"
#defined "ANY" "foo"
removeMethod("Compare",c(e1="ANY",e2="foo"))
#[1] TRUE
2>o
##Called from: 2 > o ### What?? Even after removing method the first
defined
### method is still there!!!!
#Browse[1]>
#[1] TRUE FALSE
I tried this under Windows Xp in 2.8 and 2.9.0.
Vitalie.
______________________________________________
R-help@r-project.org mailing list
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.