On Apr 28, 2011, at 3:21 PM, Jannis wrote:

> On 04/28/2011 09:53 PM, Benjamin Caldwell wrote:
>> rws50<- subset(rw.fire.RW,shigo.av<50)
> 
> quick and dirty would be to replace all NAs with -99999 (or similar), use 
> subset, and set all values ==-99999 in the subset back to NA. There may be 
> more elegant solutions, though.
> 


Indeed. See ?is.na

DF <- data.frame(A = 1:20, B = c(1:15, rep(NA, 5)))

> subset(DF, B > 10)
    A  B
11 11 11
12 12 12
13 13 13
14 14 14
15 15 15

> subset(DF, (B > 10) | is.na(B))
    A  B
11 11 11
12 12 12
13 13 13
14 14 14
15 15 15
16 16 NA
17 17 NA
18 18 NA
19 19 NA
20 20 NA


HTH,

Marc Schwartz

______________________________________________
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.

Reply via email to