[Rd] Problem with 'drop' for 1-D arrays? (PR#4110)

richard_raubertas at merck.com richard_raubertas at merck.com
Tue Sep 9 17:54:03 MEST 2003


R 1.7.1 on Windows XP

The argument 'drop' appears to be ignored when subscripting
1-dimensional arrays (i.e., arrays whose 'dim' attribute has 
length 1):

> x <- array(1:5, dim=c(5))
> dim(x)
[1] 5
> dim(x[, drop=TRUE])   # Shouldn't this be NULL?
[1] 5
> dim(x[2:3])  # This seems right:  default is drop=TRUE
NULL
> dim(x[2:3, drop=FALSE])  # But this seems wrong
NULL

Note that the behavior with a 2-D array is different:

> y <- array(1:5, dim=c(1,5))
> dim(y)
[1] 1 5
> dim(y[,,drop=TRUE])
NULL
> dim(y[,2:3])
NULL
> dim(y[,2:3,drop=FALSE])
[1] 1 2

Rich Raubertas
Biometrics Research, RY33-300
Merck & Co.

------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}



More information about the R-devel mailing list