On 25/01/2011 8:07 p.m., typhoong wrote:
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
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 -- _________________________________________________________________ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.