[R] subsetting a data frame using string matching

Karin Lagesen karin.lagesen at medisin.uio.no
Mon Jan 21 11:18:59 CET 2008

Example data frame: 

a = c("Alpha", "Beta", "Gamma", "Beeta", "Alpha", "beta")
b = c(1:6)
example = data.frame("Title" = a, "Vals" = b)

> example
  Title Vals
1 Alpha    1
2  Beta    2
3 Gamma    3
4 Beeta    4
5 Alpha    5
6  beta    6

I would like to be able to get a new data frame from this data frame
containing only rows that match a certain string. In this case it
could for instance be the string "eta". I have tried various ways of
using agrep and grep, but so far I have not found anything that

Thankyou in advance for your help!

Karin Lagesen, PhD student
karin.lagesen at medisin.uio.no

More information about the R-help mailing list