"[" not "[<-"

Martyn Plummer plummer@iarc.fr
Wed, 18 Nov 1998 18:22:23 +0100


Paul Gilbert wrote:
> 
> Brian Ripley writes
> >on any of these, but it is less clear what [] should do. As it is not
> >clear if the attributes apply to the whole object only, I suspect stripping
> >is right.
> 
> I have played with this some and the answer is not obvious. There are some
> attributes it would be nice to keep and others it would be better to strip. My
> tframe attribute has to be consistent with the first dimension of the matrix, so
> it either has to be modified when the dim is modified or it has to be stripped
> so that there is not conflicting information. I have learned to live with the
> latter.

Couldn't you use the object-oriented features of R? For objects of class
"foo", subsetting can be done using the "[.foo" function. Attributes can be
saved
before passing the data on to NextMethod (which would strip attributes it
doesn't
know about). Then the saved attributes could be restored, possibly in a
modified
form, if the object is still of class "foo".

I had assumed that this was the logic of subsetting, but it would be nice
if someone could confirm this.

Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._