Skip to content

Extract NA data rows

6 messages · typhoong, David Scott, kamel gaanoun +2 more

#
hi i have the following dataframe 

x	y
1	345
6	NA
8	123
32	123
12	NA
6	124
7	NA

and i want to extract the data rows which contains "NA" data, I tried

subset(dataframe,y=="NA") 

but fail. if you know the answers, please let me know thanks.

typhoong
#
On 25/01/2011 8:07 p.m., typhoong wrote:
Your test is wrong for NA. You must use is.na:

 > df
    x   y
1  1 345
2  6  NA
3  8 123
4 32 123
5 12  NA
6  6 124
7  7  NA
 > subset(df, is.na(y))
    x  y
2  6 NA
5 12 NA
7  7 NA
#
Hi

r-help-bounces at r-project.org napsal dne 25.01.2011 08:07:10:
See

?is.na

however ?complete.cases is my preferred choice when working with data 
frames and several columns.

dataframe[complete.cases(dataframe),]

Regards
Petr
http://r.789695.n4.nabble.com/Extract-NA-data-
http://www.R-project.org/posting-guide.html
#
Hi!

Try
subset(dataframe, is.na(y))

or
df[is.na(df$y),]

HTH,
Ivan

Le 1/25/2011 08:07, typhoong a ?crit :