[Rd] NextMethod ignoring changed argument

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Wed 27 Oct 2004 - 14:39:51 EST

Is this a bug? We define the [ operator for class test. All it does is force drop to be FALSE and then calls the NextMethod. If we specify drop= in the call then it works as expected (### 2 and ### 3) but if we do not specify drop (### 1) then it acts as if drop=TRUE even though we have set it to FALSE within [.test .

> "[.test" <- function(x, i, j, drop = TRUE) {

+ drop <- FALSE
+ NextMethod("[") 
+ }

> x <- structure(matrix(1:12, 4, 3), class = "test")

> x[1,] ### 1 - why does it ignore drop=FALSE in [.test ????
[1] 1 5 9

> x[1,,drop = TRUE] ### 2 - ok

     [,1] [,2] [,3]
[1,] 1 5 9
> x[1,,drop = FALSE] ### 3 - ok

     [,1] [,2] [,3]
[1,] 1 5 9
> R.version.string # windows XP

[1] "R version 2.0.0, 2004-10-04"



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Oct 27 14:45:53 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:58 EST