Luca: Well, start by using the correct syntax -- you've misplaced your quotes.
Then look at existing code, e.g. base:::"[.factor" A little effort on your part obviates the need to post here. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch On Thu, May 29, 2014 at 1:04 AM, Luca Cerone <luca.cer...@gmail.com> wrote: > 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 > > ______________________________________________ > 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. ______________________________________________ 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.