[R] 'callNextMethod' in a '[<-' function does not work ?
cgenolin
cgenolin at u-paris10.fr
Fri Dec 9 19:15:29 CET 2011
Hi the list,
I try to use callNextMethod in a setteur ([<-) but it does not work.
Any raison ?
Any other option ?
--- 8< ------------------
### Class B0 ###
setClass("B0" , representation(b0 = "numeric"))
setReplaceMethod("[","B0",function(x,i,j,value){x at b0 <- -value})
a <- new("B0")
a at b0 <- 3
a
a["b0"] <- 3
a
### Class B1 ###
setClass("B1", representation(b1 = "character"), contains = "B0")
setReplaceMethod("[","B1",function(x,i,j,value){
value <- value*2
callNextMethod()
})
b <- new("B1")
try(b["b0"] <- 5)
--- 8< ------------------
Christophe
--
View this message in context: http://r.789695.n4.nabble.com/callNextMethod-in-a-function-does-not-work-tp4177669p4177669.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list