On Aug 6, 2014, at 10:07 AM, Terrence Ireland wrote:
> There seems to be a result type difference when subscripting a 6 x 1 matrix
> as compared to a 3 x 2 matrix that is caused by the ncol = 1 compared to ncol
> > 1.
>
> > ThinMatrix <- matrix(1:6,ncol=1)
> > ThinMatrix
> [,1]
> [1,]1
You want `drop=FALSE`:
> dim(ThinMatrix[TRUE, , drop=FALSE])
[1] 6 1
>From ?"[":
drop: For matrices and arrays. If ‘TRUE’ the result is coerced to
the lowest possible dimension (see the examples). This only
works for extracting elements, not for the replacement. See
There seems to be a result type difference when subscripting a 6 x 1
matrix as compared to a 3 x 2 matrix that is caused by the ncol = 1
compared to ncol > 1.
> ThinMatrix <- matrix(1:6,ncol=1)
> ThinMatrix
[,1]
[1,]1
[2,]2
[3,]3
[4,]4
[5,]5
[6,]6
> FatMatrix <- mat