Skip to content

subset without removing NAs

5 messages · Benjamin Caldwell, Jannis, Marc Schwartz +1 more

#
On 04/28/2011 09:53 PM, Benjamin Caldwell wrote:
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.


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

            
Indeed. See ?is.na

DF <- data.frame(A = 1:20, B = c(1:15, rep(NA, 5)))
A  B
11 11 11
12 12 12
13 13 13
14 14 14
15 15 15
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
#
On Apr 28, 2011, at 3:53 PM, Benjamin Caldwell wrote:

            
If you use "[" instead the NA's will come though:

rw.fire.RW[ shigo.av<50, ]

In fact I generally wrap my logicals in which to avoid such  
(mis?)behavior. but you appear to approve of it.

==
David Winsemius, MD
West Hartford, CT