[Rd] "[.data.frame" allows un-named 3rd subscript (PR#989)
Charles C. Berry
Mon, 18 Jun 2001 14:09:49 -0700 (PDT)
On 18 Jun 2001, Peter Dalgaard BSA wrote:
> email@example.com writes:
> > Since the Extract page has usage as:
> > x[i, j, ... , drop=TRUE]
> > I would expect that 'drop=' would need to be given to the third 'subscript'
> > > diag(4)[ , 4 , 4 ] # Forgot 'drop=' or added extra ','
> > Error in diag(4)[, 4, 4] : incorrect number of dimensions
> > >
> > > as.data.frame( diag(4) )[ , 4 , 4 ] # should return error, right?
> >  0 0 0 1
> And the bug is?
> The generic indexing should really be x[...,drop=T]. Methods for
> specific classes can specialize to a particular number of indices if
> they want to, which is what is happening here
> > get ("[.data.frame")
> function (x, i, j, drop = if (missing(i)) TRUE else length(cols) ==
> one could fairly easily slip in a "..." argument after "j", and then
> inside the function give an error if "..." is not empty, but what
> would the point be?
The point would be to catch errors like this
for ( i in 1:2 ) foo[i,2] <- my.fun( bar[,i,2] , another.arg )
that might otherwise pass unnoticed when 'bar' is a data.frame.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:firstname.lastname@example.org UC San Diego
http://hacuna.ucsd.edu/members/ccb.html La Jolla, San Diego 92093-0645
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: email@example.com