Uwe: 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.
>pat=c("ATCGTTTGCTAC", "GGCTAATGCATTGC"); > grep ("TGC", pat) [1] 1 2 grep only tells me the position of first occurrence in each element whereas the second element contains two "TGC"s. >>> Uwe Ligges <[EMAIL PROTECTED]> 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. Uwe Ligges > Thanks a lot. > > Sean > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html