Skip to content
Prev 58774 / 398502 Next

remove missing values from matrix or data frame

How about the following: 

 > (A <- array(c(1, NA, 3, NA, 4, 5), dim=c(3,2)))
     [,1] [,2]
[1,]    1   NA
[2,]   NA    4
[3,]    3    5
 > A[apply(A, 1, function(x)!any(is.na(x))), , drop=F]
     [,1] [,2]
[1,]    3    5

      hope this helps.  spencer graves
William Briggs wrote: