[R] subsetting a data frame using string matching

From: Karin Lagesen <karin.lagesen_at_medisin.uio.no>
Date: Mon, 21 Jan 2008 11:18:59 +0100

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 worked.

Thankyou in advance for your help!

Karin

-- 
Karin Lagesen, PhD student
karin.lagesen_at_medisin.uio.no
http://folk.uio.no/karinlag

______________________________________________
R-help_at_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.
Received on Mon 21 Jan 2008 - 10:21:07 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 Mon 21 Jan 2008 - 11:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive