[R] Subset function: selecting variables within a factor

Thomas Lumley tlumley at u.washington.edu
Tue Apr 14 05:28:50 CEST 2009


On Tue, 14 Apr 2009, Andrew McFadden wrote:

> Hi all
>
> I know this must be an easy one so sorry for the trouble. I would like
> to select a list of variables within a factor
> The following example is given in help for subset:
>
> subset(airquality, Temp  > 80 select = c(Ozone, Temp))
>
> So how do I select all temperatures of 90 and 80 ie Temp = c(80,90)


subset(airquality, Temp %in% c(80,90))

    -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list