Re: [R] subset without removing NAs

From: David Winsemius <>
Date: Thu, 28 Apr 2011 17:02:40 -0400

On Apr 28, 2011, at 3:53 PM, Benjamin Caldwell wrote:

> Hi folks,
> I'm dealing with a dataset with a lot of NAs, and want to use subset
> on the
> data without removing the NAs from the the dataframe; e.g.
> rws50 <- subset(,shigo.av<50)
> This removes instances with NA for the value in addition to anything
> <50.
> Any suggestions much appreciated.

If you use "[" instead the NA's will come though:[ 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 mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 28 Apr 2011 - 21:04:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Apr 2011 - 21:20:39 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive