is it possible to have a matrix with 1 row only in R?
Here is my code:
nas <- which(!is.na(y)) x <- x[nas,] y <- y[nas] ...
You need to specify drop = FALSE to stop R coercing a matrix or array to the lowest possible number of dimensions. See ?`[` for more details.
drop = FALSE
R
?`[`
x <- matrix(1:4,ncol=2) x[1,] ## [1] 1 2 x[1,,drop=F] ## [,1] [,2] ## [1,] 1 3