[R] Redefine `[` for S3 class
Luca Cerone
luca.cerone at gmail.com
Thu May 29 10:04:58 CEST 2014
Dear all,
I have defined my own class "myclass" using S3 class styles.
A myclass objects is just a matrix with some attribute attached.
When I subset my myclass the resulting matrix (or vector) doesn't
have the attributes attached.
I would like to redefine the `[` function for myclass objects (it has to behave
the same as the standard function but just attach the attributes to the subset).
I have tried to define the method:
`['.myclass <- function(X,... ) { etc...}
but it doesn't work ( I realized after that `[` is a .Primitive).
How can I define this method for my own class?
Thanks a lot in advance for the help,
Cheers,
Luca
More information about the R-help
mailing list