Skip to content
Prev 273334 / 398506 Next

How to subset() from data frame using specific rows

This isn't going to be the most elegant, but it should work:

## Get the factors as characters

ff <- as.character(chemdata$site)

## Identify those that match what you want
ff <- grepl(ff, "BC-")

now use this logical vector to subset

chemdata[ff, ]

Can't test, but should be good to go assuming that "BC-" entirely
identifies those sites you want. If you have other "BC-" things read
through the ?regex documentation and I think it describes how to do
selective wildcards

Michael
On Tue, Oct 4, 2011 at 2:39 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote: