Prevent drop dimension attribute by drop = FALSE.
test.matrix <- matrix(1:15, nc=5)
> test.matrix[1, ]
[1] 1 4 7 10 13
> test.matrix[1, , drop=FALSE]
[,1] [,2] [,3] [,4] [,5]
[1,] 1 4 7 10 13
Prevent drop dimension attribute by drop = FALSE.
test.matrix <- matrix(1:15, nc=5)
> test.matrix[1, ]
[1] 1 4 7 10 13
> test.matrix[1, , drop=FALSE]
[,1] [,2] [,3] [,4] [,5]
[1,] 1 4 7 10 13
Leave a Reply