[R] Indexing issue

Swidan, Firas swidanf at janelia.hhmi.org
Tue Aug 1 21:57:01 CEST 2006


Hi,

R is having the following weird behavior and I am not sure if that is a
feature or a bug:

I am working on the following "3D" array:

> bIm
, , 1

     [,1]
[1,] TRUE
[2,] TRUE
[3,] TRUE
[4,] TRUE
[5,] TRUE

> class(bIm)
[1] "array"
> dim(bIm)
[1] 5 1 1

When I try to get the first 2D subarray, the whole thing folds into a
vector:

> bIm[,,1]
[1] TRUE TRUE TRUE TRUE TRUE

This causes a lot of trouble in the R code as one would have expected to get
a 2D array but ends up with this "logical" vector.

Is this the way it was meant to be? Does not this behavior bother anyone
else besides me?

Thanks for the help,
Firas.



More information about the R-help mailing list