I think na.rm usually only works in functions, say, for the middle function. I would go with complete.cases: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/complete.cases.htm
let's say you have the following 3x3 matrix:
x <- matrix(c(1:8, NA), 3, 3) > x [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 NA
then you can get full cases of this matrix with
y <- x[complete.cases(x),] > y [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8
The complete.cases function returns a vector of truth values ββthat says whether the case is complete:
> complete.cases(x) [1] TRUE TRUE FALSE
and then you index the rows of the matrix x and add "," to say that you want all the columns.
jonlemon
source share