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 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 get here is that the
subsequence is found twice.



Any idea how can I do this?



Thanks in advance





Marcelo Araya-Salas

Ph.D.  Student

Avian Communication and Evolution Lab

Department of Biology

New Mexico State University

Lab: 575-646-4863




        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Dept. Mammalogy
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to