[R] 'methods' and "[<-"

Laurent Gautier laurent at cbs.dtu.dk
Sun Mar 2 05:40:04 CET 2003


Dear List,

I am trying to override the replace method "[<-" for
objects of class "matrix"... with little success...

Would anyone know where I am wrong ?

> library(methods)
> setReplaceMethod("[", "matrix", function(x, i, j, ..., value) {cat("I'm here.\n")})
[1] "[<-"
> m <- new("matrix", 0, 5, 2)
> m[1,1] <- 2
> 
# ..did not use my new method it seems



Thanks,


L/


PS: I am using R-1.6.2




More information about the R-help mailing list