Skip to content
Prev 275494 / 398506 Next

Extracting dataframe rows containing NAs in one column

kaallen wrote:
I am sure others will have cleaner approaches but how about ....

# Data
temp = data.frame(Day=1:6,Month=1, Year=c(NA,1959,NA,1959,1959,1959),
PW=c(6,7,8,NA,10,11))

# Extract Any Row Containing an NA
myNAs = temp[apply(temp,1,function(x) any(is.na(x))),]

HTH

Pete


--
View this message in context: http://r.789695.n4.nabble.com/Extracting-dataframe-rows-containing-NAs-in-one-column-tp3937361p3937523.html
Sent from the R help mailing list archive at Nabble.com.