Dear R-experts,
I'm looking for an easy possibility for pattern search. I have got a
string and a special pattern. I would like to know if the pattern
appears in the string, if yes where does it appear (position) and the
number of appearance.
Example:
Text = c(If the sun shines, no clouds
how about:
length(gregexpr(the, Text)[[1]])
?
b
On Apr 4, 2007, at 10:49 AM, Schmitt, Corinna wrote:
Dear R-experts,
I'm looking for an easy possibility for pattern search. I have got a
string and a special pattern. I would like to know if the pattern
appears in the string, if yes where
Hi,
I'm looking for an easy possibility for pattern search. I have got a
string and a special pattern. I would like to know if the pattern
appears in the string, if yes where does it appear (position) and the
number of appearance.
Example:
Text = c(If the sun shines, no clouds should
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
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
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
Sean Liang SLiang at wyeth.com writes:
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