[R] pattern search
SLiang at wyeth.com
Fri Oct 29 20:40:52 CEST 2004
Thanks for getting back to me. My situation is a bit more complicated.
I have a vector of sequences each of which might contain any number of a
given pattern (e.g.
> grep ("TGC", pat)
 1 2
grep only tells me the position of first occurrence in each element
whereas the second element contains two "TGC"s.
>>> Uwe Ligges <ligges at statistik.uni-dortmund.de> 10/29/2004 2:27:27 PM
Sean Liang wrote:
> hi, I like to find a pattern within a giver sequence. There might be
> multiple occurences of the pattern. I like to know the number of
> occurences and the positions if possible. "grep" can tell me if a
> pattern exists but can't give me the information I need. Does anyone
> know any function that I can use or know how to do what I intend?.
gr <- grep("a", c("a", "b", "a"))
grep tells you that the positions are 1 and 3. length(gr) tells you
there are two occurences.
> Thanks a lot.
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help