cberry@tajo.ucsd.edu
2001-Jun-18 20:10 UTC
[Rd] "[.data.frame" allows un-named 3rd subscript (PR#989)
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?[1] 0 0 0 1 Also note:> diag(4)[ , , drop=TRUE ][,1] [,2] [,3] [,4] [1,] 1 0 0 0 [2,] 0 1 0 0 [3,] 0 0 1 0 [4,] 0 0 0 1> > as.data.frame( diag(4) )[ , , drop=TRUE ]Error in [.data.frame(as.data.frame(diag(4)), , , drop = 4) : Argument "j" is missing, with no default>--please do not edit the information below-- Version: platform = sparc-sun-solaris2.7 arch = sparc os = solaris2.7 system = sparc, solaris2.7 status = major = 1 minor = 2.3 year = 2001 month = 04 day = 26 language = R Search Path: .GlobalEnv, package:nls, package:nlme, package:ctest, Autoloads, package:base Chuck -- Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry@tajo.ucsd.edu 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: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2001-Jun-18 20:38 UTC
[Rd] "[.data.frame" allows un-named 3rd subscript (PR#989)
cberry@tajo.ucsd.edu 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? > [1] 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) == 1) 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? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._