Hi,
On Jul 21, 2009, at 1:47 PM, Mehdi Khan wrote:
Hello all,
I have a seemingly simple question which I have searched for an
answer for
for a few hours without luck. I have a matrix of both values and
characters
with thousands of rows. I would like to run a search of this matrix
for
certain values and would like the search to retrieve the entire
row. How
would I accomplish this?
Are the characters and values (numeric, I guess(?)) in their own
respective columns? If so, make sure you use a data frame.
That having been said:
R> df <- data.frame(nums=1:10, words=c("Abelonian",
"abeltree",
"Abencerrages",
"abenteric",
"abepithymia",
"Aberdeen",
"aberdevine",
"Aberdonian",
"Aberia",
"aberrance"))
R> idxs <- grep('ia', df$words)
R> df[idxs,]
nums words
1 1 Abelonian
5 5 abepithymia
8 8 Aberdonian
9 9 Aberia
Is something like that what you're after?
-steve
--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
______________________________________________
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.