Skip to content
Prev 175767 / 398506 Next

A query about na.omit

On 01-Apr-09 15:49:40, Jose Iparraguirre D'Elia wrote:
Roll up your sleeves, and spell out in detail the condition you need:

  DF<-data.frame(x=c(1,2,3,4,NA),y=c(1,2,3,NA,5),z=c(1,2,NA,4,5))
  DF
#    x  y  z
# 1  1  1  1
# 2  2  2  2
# 3  3  3 NA
# 4  4 NA  4
# 5 NA  5  5

  DF[!(is.na(rowSums(DF[,(1:2)]))),]
#   x y  z
# 1 1 1  1
# 2 2 2  2
# 3 3 3 NA

Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 01-Apr-09                                       Time: 18:00:53
------------------------------ XFMail ------------------------------