[R] subset with NA

Robert Schick Robert.Schick at noaa.gov
Thu Feb 20 02:12:04 CET 2003


Easy question that I can't find an answer for. I'm trying to subset a
data frame and want to exclude the positive values, i.e. I want the NA
values. 

My data:
> summary(temp$tuna)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
      1       2       3       3       4       5    1211 

Querying for 
subset(temp, tuna %in% "NA", select....
subset(temp, tuna == NA, select....
subset(temp, tuna == as.character(NA), select....

All yield an empty data frame.

An R-help post
(http://www.r-project.org/nocvs/mail/r-help/2002/3645.html) suggested
looking at http://developer.r-project.org/150update.txt, which I did
but I'm confused as to how to accurately query for an NA string.


-- 
Rob Schick
Ecologist
NOAA Fisheries
Santa Cruz Lab
110 Shaffer Road
Santa Cruz, CA 95060
Phone: 831.420.3960




More information about the R-help mailing list