... and, as an aside, if you had simply searched within R for (the
obvious?!)

??wildcard

you would have received the suggestion for glob2rx() in utils, which
actually would have enabled you to use a familiar wildcard expression.
However, the answers you've already received are simpler and more
straightforward.

-- Bert

On Tue, Oct 4, 2011 at 12:03 PM, Sarah Goslee <sarah.gos...@gmail.com>wrote:

> Hi Rich,
>
> On Tue, Oct 4, 2011 at 2:58 PM, Rich Shepard <rshep...@appl-ecosys.com>
> wrote:
> > On Tue, 4 Oct 2011, Sarah Goslee wrote:
> >
> >> You can use something like this:
> >>
> >>> testdata <- c("A1", "A2", "A3", "B1", "B2", "B3")
> >>> grep("^A", testdata)
> >>
> >> [1] 1 2 3
> >>>
> >>> grepl("^A", testdata)
> >>
> >> [1]  TRUE  TRUE  TRUE FALSE FALSE FALSE
> >
> > Sarah,
> >
> >  I don't see how this gives me a data frame containing only those sites I
> > specify. I want to plot by sites-within-streams specifying which param
> > factor to use.
>
>
> You asked for pointers, and didn't provide a reproducible example, so
> I offered a
> pointer.
>
> If you have a logical vector that specifies whether to include or omit
> a row, you
> can use that to subset your data frame.
>
> sitesToUse <- grepl("firstsite", mydata$mysitenames)
> dataframeForThatSite <- mydata[sitesToUse, ]
>
> If you want real worked results, you'll need to provide a reproducible
> example
> of your own.
>
> Sarah
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> ______________________________________________
> 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.
>



-- 
"Men by nature long to get on to the ultimate truths, and will often be
impatient with elementary studies or fight shy of them. If it were possible
to reach the ultimate truths without the elementary studies usually prefixed
to them, these would not be preparatory studies but superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

        [[alternative HTML version deleted]]

______________________________________________
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