On Tue, Sep 27, 2011 at 6:15 PM, Jean V Adams wrote:
> For example,
>
> songs <- c("ABCABAABABABCAB", "ABACAB", "ABABCABCBC")
> counts <- gregexpr("ABC", songs)
> sapply(counts, length)
That will still return '1' for the case where its not found, because of the -1.
sapply(counts,function(x){su
Barry Rowlingson wrote on 09/27/2011 12:06:21 PM:
>
> On Tue, Sep 27, 2011 at 5:51 PM, Marcelo Araya
wrote:
> > Hi all
> >
> >
> >
> > I am analyzing bird song element sequences. I would like to know how
can I
> > get how many times a given subsequence is found in single string
sequence.
> >
>
On Tue, Sep 27, 2011 at 5:51 PM, Marcelo Araya wrote:
> Hi all
>
>
>
> I am analyzing bird song element sequences. I would like to know how can I
> get how many times a given subsequence is found in single string sequence.
>
>
>
>
>
> For example:
>
>
>
> If I have this single sequence:
>
>
>
> AB
Hi Marcelo,
Try this:
x <- "ABCABAABABABCAB"
length(gregexpr(pattern="ABC", x)[[1]])
See ?gregexpr for more details (though I admit that it is not easy to
understand this help page)
HTH,
Ivan
Le 9/27/2011 18:51, Marcelo Araya a écrit :
Hi all
I am analyzing bird song element sequences. I
Hi all
I am analyzing bird song element sequences. I would like to know how can I
get how many times a given subsequence is found in single string sequence.
For example:
If I have this single sequence:
ABCABAABABABCAB
I am looking for the subsequence "ABC". Want I need to g
5 matches
Mail list logo