[R] pattern search

2007-04-04 Thread Schmitt, Corinna
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

Re: [R] pattern search

2007-04-04 Thread Benilton Carvalho
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

Re: [R] pattern search

2007-04-04 Thread Julien Barnier
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

[R] pattern search

2004-10-29 Thread Sean Liang
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

Re: [R] pattern search

2004-10-29 Thread Uwe Ligges
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

Re: [R] pattern search

2004-10-29 Thread Sean Liang
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

Re: [R] pattern search

2004-10-29 Thread Gabor Grothendieck
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