6

Possible Duplicate:
Removing empty rows of a data file in R

Suppose I have a dataframe df

I would like to select the rows from it, where any of the variables in the row are not NA. That is to say I only want to exclude the rows in which all the variables are NA

Community
  • 1
  • 1
Joe King
  • 2,955
  • 7
  • 29
  • 43
  • OK thanks - I found it here http://stackoverflow.com/questions/6471689/remove-rows-in-r-matrix-where-all-data-is-na – Joe King Jul 05 '12 at 10:31
  • Joe, I've been meaning to check out the `mice` package, but there's another package called `mix` that implements some MI methods, too. I recall from a bunch of years ago when I was using that package that there's a function called `prelim.mix` that provides a lot of good information on the missingness of your variables. – BenBarnes Jul 05 '12 at 11:34

1 Answers1

13
df[apply(!is.na(df), 1, any), ]
Thierry
  • 18,049
  • 5
  • 48
  • 66