[R] pattern search
ligges at statistik.uni-dortmund.de
Fri Oct 29 20:27:27 CEST 2004
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! http://www.R-project.org/posting-guide.html
More information about the R-help