<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Marcelo,<br>
<br>
Nice to know that TraMineR is used to analyse birds songs. Before we
add this feature in the next TraMineR version, what I can do for you
is this modified version of the seqpm function. You can copy-paste
it into your console.<br>
<br>
<tt>seqpm2 <- function(seqdata, pattern) {<br>
<br>
if (!inherits(seqdata,"stslist")) {<br>
stop("data is not a sequence object, use 'seqdef' function
to create one")<br>
}<br>
<br>
match <- matrix(0, nrow=nrow(seqdata), ncol=1)<br>
rownames(match) <- rownames(seqdata)<br>
colnames(match) <- "matches"<br>
<br>
pl <- length(seqdecomp(pattern, sep=""))<br>
<br>
for (i in 1:(ncol(seqdata)-pl)) {<br>
tmp <- seqconc(seqdata[,i:(i+(pl-1))],sep="")<br>
pm <- grep(pattern,tmp)<br>
match[pm] <- match[pm]+1<br>
}<br>
<br>
<br>
return(match)<br>
}</tt><br>
<br>
This function returns a vector with the number of matches in each
sequence of your sequence object:<br>
<br>
<tt>> s1 <- seqdef("A-B-C-A-B-A-B-A-B-A-B-A-B-A-B-A-B-C-A-B")<br>
<br>
> seqpm2(s1, "ABC")<br>
matches<br>
[1] 2<br>
</tt><br>
<br>
If you have several sequences <br>
<br>
<tt>> ex <- c("A-B-C-A-B-A-B-A-B-A-B-A-B-A-B-A-B-C-A-B",
"A-B-B-A-B-A-B-A-B-A-B-A-B-A-B-A-B-C-A-B")<br>
<br>
> ex.seq <- seqdef(ex)<br>
<br>
> ex.seq<br>
Sequence <br>
[1] A-B-C-A-B-A-B-A-B-A-B-A-B-A-B-A-B-C-A-B<br>
[2] A-B-B-A-B-A-B-A-B-A-B-A-B-A-B-A-B-C-A-B<br>
<br>
> seqpm2(ex.seq, "ABC")<br>
matches<br>
[1] 2<br>
[2] 1</tt>
<br>
<br>
By the way, it is easier for us if you subscribe to the users list
(see <a class="moz-txt-link-freetext" href="http://mephisto.unige.ch/traminer/contrib.shtml">http://mephisto.unige.ch/traminer/contrib.shtml</a>) before sending
questions. And if you write a paper about birds songs using
TraMineR, we would be pleased to add it to our "who uses it" page!<br>
<br>
All the best,<br>
Alexis<br>
<br>
<br>
<br>
<br>
Le 26. 09. 11 02:33, Marcelo Araya a écrit :
<blockquote cite="mid:000001cc7be3$f4988290$ddc987b0$@gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 0 5 0 0 0 0 0 0 0;}
@font-face
        {font-family:Helvetica;
        panose-1:2 0 5 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EstiloCorreo17
        {mso-style-type:personal-compose;
        font-family:Helvetica;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">Hi all<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">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. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">For example:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">If I have this single sequence:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-family: Helvetica;
color: rgb(31, 73, 125);">ABC</span></b><span
style="font-family: Helvetica; color: rgb(31, 73, 125);">ABABABABABAB<b>ABC</b>AB<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">If I am looking for the subsequence
“ABC”. Want I need to get here is that the subsequence is
found twice. The function “seqpm” just tell me if the
subsequence is there or not.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">Thanks in advance<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);" lang="ES">Marcelo Araya-Salas<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);" lang="ES">Ph.D.</span><span
style="font-family: Helvetica; color: rgb(31, 73, 125);"
lang="ES"> </span><span style="font-family: Helvetica;
color: rgb(31, 73, 125);" lang="ES"> </span><span
style="font-family: Helvetica; color: rgb(31, 73, 125);">Student<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">Avian Communication and Evolution Lab<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">Department of Biology<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">New Mexico State University<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Helvetica; color:
rgb(31, 73, 125);">Lab: 575-646-4863<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Traminer-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Traminer-users@lists.r-forge.r-project.org">Traminer-users@lists.r-forge.r-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users</a>
</pre>
</blockquote>
<br>
</body>
</html>