<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    Thanks a lot Thomas, Hadrien and Gilbert.<br>
    <br>
    The HSPELL_TO_STS function is very usefull indeed, but it supposes
    that begin and end variables be numeric, which is not my case since
    I have dates. And converting dates into numbers originating from the
    most ancient date of the first episode seems to me much quicker with
    SPELL format.<br>
    <br>
    So here is one way of converting my HSPELL data into SPELL. Very
    close to Thomas' suggestion (might not be the most elegant script...
    but it does the job):<br>
    <br>
    d <- read.csv2("~ ... example.csv")<br>
    <br>
    f <-
    data.frame(ident=NULL,deb=NULL,fin=NULL,etat=NULL,motif=NULL)<br>
    <br>
    i <- 1<br>
    for(i in 1:20){<br>
      e <- d[,names(d) %in%
    c("ident",paste0(c("deb","fin","etat","motif"),as.character(i)))]<br>
      names(e) <- c("ident","deb","fin","etat","motif")<br>
      f <- rbind(f,e)<br>
    }<br>
    <br>
    # ordering by identifiers<br>
    f <- f[order(f$ident),]<br>
    <br>
    # deleting empty rows<br>
    f <- subset(f, deb!="")<br>
    <br>
    # counting the number of episodes by individual<br>
    dim <- nrow(f) <br>
    f <- cbind(f,rep(1,dim))<br>
    colnames(f)[6]<-"nbepis"<br>
    <br>
    for (i in 1:(dim-1))<br>
    {<br>
      if (f[i+1, 1] == f[i, 1])<br>
      {<br>
        f[i+1, 6] <- f[i, 6]+1<br>
      }<br>
      <br>
    }<br>
    <br>
    # checking that maximum number of episodes is equal to 20<br>
    max(f$nbepis)<br>
    <br>
    <br>
    For those who would like to see the actual result: see the example
    dataset attached.<br>
    <br>
    Best,<br>
    <br>
    Anton<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">Le 11/06/2015 08:57, Gilbert Ritschard
      a écrit :<br>
    </div>
    <blockquote
      cite="mid:66ABD43696E3DB4687E0BB396A76E5F10A1093E0@golf.isis.unige.ch"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]-->
      <style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@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:12.0pt;
        font-family:"Times New Roman",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.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">You
            could also consider the HSPELL_to_STS function provided by
            the TraMineRextras package.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b><span
                  style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif">
                <a class="moz-txt-link-abbreviated" href="mailto:traminer-users-bounces@lists.r-forge.r-project.org">traminer-users-bounces@lists.r-forge.r-project.org</a>
                [<a class="moz-txt-link-freetext" href="mailto:traminer-users-bounces@lists.r-forge.r-project.org">mailto:traminer-users-bounces@lists.r-forge.r-project.org</a>]
                <b>On Behalf Of </b>Hadrien Commenges<br>
                <b>Sent:</b> Thursday, June 11, 2015 08:45<br>
                <b>To:</b> Users questions<br>
                <b>Subject:</b> Re: [Traminer-users] Format of sequences<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <div>
            <p class="MsoNormal"><span
                style="font-family:"Arial",sans-serif;color:black">You
                could also split your table by set of columns (columns
                1:4, then col c(1, 5:7), etc.) and then rbind() all the
                tables.<o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span
                style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span
                style="font-family:"Arial",sans-serif;color:black">Another
                option would be the melt() function in the reshape2
                package.<o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span
                style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
          </div>
          <div class="MsoNormal" style="text-align:center"
            align="center"><span
              style="font-family:"Arial",sans-serif;color:black">
              <hr id="zwchr" align="center" size="2" width="100%">
            </span></div>
          <div>
            <p class="MsoNormal"><b><span
                  style="font-family:"Helvetica",sans-serif;color:black">De:
                </span></b><span
                style="font-family:"Helvetica",sans-serif;color:black">"thomas
                collas" <<a moz-do-not-send="true"
                  href="mailto:thomas.collas@gmail.com">thomas.collas@gmail.com</a>><br>
                <b>À: </b>"Users questions" <<a
                  moz-do-not-send="true"
                  href="mailto:traminer-users@lists.r-forge.r-project.org">traminer-users@lists.r-forge.r-project.org</a>><br>
                <b>Envoyé: </b>Mercredi 10 Juin 2015 21:03:05<br>
                <b>Objet: </b>Re: [Traminer-users] Format of sequences<o:p></o:p></span></p>
            <div>
              <p class="MsoNormal"><span
                  style="font-family:"Helvetica",sans-serif;color:black"><o:p> </o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
                  style="font-family:"Helvetica",sans-serif;color:black">Addendum
                  : Do not forget to keep the ID column with the three
                  other columns at each iteration.<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
                  style="font-family:"Helvetica",sans-serif;color:black"><o:p> </o:p></span></p>
              <div>
                <p class="MsoNormal"><span
                    style="font-family:"Helvetica",sans-serif;color:black">2015-06-10
                    21:01 GMT+02:00 thomas collas <<a
                      moz-do-not-send="true"
                      href="mailto:thomas.collas@gmail.com"
                      target="_blank">thomas.collas@gmail.com</a>>:<br>
                    <br>
                    <o:p></o:p></span></p>
                <blockquote style="border:none;border-left:solid #CCCCCC
                  1.0pt;padding:0in 0in 0in
                  6.0pt;margin-left:4.8pt;margin-right:0in">
                  <div>
                    <p class="MsoNormal"><span
                        style="font-family:"Helvetica",sans-serif;color:black">Hello
                        Anton,<o:p></o:p></span></p>
                    <div>
                      <p class="MsoNormal"><span
                          style="font-family:"Helvetica",sans-serif;color:black">An
                          easy solution is to build a very short loop (I
                          know R is not made for loops but it's only 18
                          iterations) separating each group of  three
                          columns, turning the headings into common ones
                          (begin/end/state) and pasting each one below
                          the other.<o:p></o:p></span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span
                          style="font-family:"Helvetica",sans-serif;color:black">I
                          hope that helps,<o:p></o:p></span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span
                          style="font-family:"Helvetica",sans-serif;color:black">thomas
                          collas<o:p></o:p></span></p>
                    </div>
                  </div>
                  <div>
                    <div>
                      <div>
                        <p class="MsoNormal"><span
                            style="font-family:"Helvetica",sans-serif;color:black"><o:p> </o:p></span></p>
                        <div>
                          <p class="MsoNormal"><span
                              style="font-family:"Helvetica",sans-serif;color:black">2015-06-10
                              18:51 GMT+02:00 Anton Perdoncin <<a
                                moz-do-not-send="true"
                                href="mailto:anton.perdoncin@gmail.com"
                                target="_blank">anton.perdoncin@gmail.com</a>>:<br>
                              <br>
                              <o:p></o:p></span></p>
                          <blockquote
                            style="border:none;border-left:solid #CCCCCC
                            1.0pt;padding:0in 0in 0in
                            6.0pt;margin-left:4.8pt;margin-right:0in">
                            <p class="MsoNormal"><span
                                style="font-family:"Helvetica",sans-serif;color:black">Hi,<br>
                                <br>
                                I have sequences in the following format
                                :<br>
                                <br>
                                ID    BEGIN1        END1           
                                STATE1        BEGIN2        END2<br>
                                   STATE2  etc... until 18<br>
                                1   01/01/1950  01/01/1960          X   
                                     02/01/1960   30/01/1960<br>
                                   Y    ...<br>
                                2   01/01/1950  01/01/1960          X   
                                     02/01/1960   30/01/1960<br>
                                   Y    ...<br>
                                <br>
                                One line = one individual. Successive
                                episodes = successive columns.<br>
                                <br>
                                I know that I need to convert dates into
                                numbers: no problem with that.<br>
                                <br>
                                However, does anyone have any idea on
                                how I could convert such a df into<br>
                                an STS or SPELL format ?<br>
                                <br>
                                Thanks!<br>
                                <br>
                                Best regards,<br>
                                <br>
                                Anton Perdoncin<br>
_______________________________________________<br>
                                Traminer-users mailing list<br>
                                <a moz-do-not-send="true"
                                  href="mailto:Traminer-users@lists.r-forge.r-project.org"
                                  target="_blank">Traminer-users@lists.r-forge.r-project.org</a><br>
                                <a moz-do-not-send="true"
href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users"
                                  target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users</a><o:p></o:p></span></p>
                          </blockquote>
                        </div>
                        <p class="MsoNormal"><span
                            style="font-family:"Helvetica",sans-serif;color:black"><o:p> </o:p></span></p>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
              <p class="MsoNormal"><span
                  style="font-family:"Helvetica",sans-serif;color:black"><o:p> </o:p></span></p>
            </div>
            <p class="MsoNormal"><span
                style="font-family:"Helvetica",sans-serif;color:black"><br>
                _______________________________________________<br>
                Traminer-users mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:Traminer-users@lists.r-forge.r-project.org">Traminer-users@lists.r-forge.r-project.org</a><br>
                <a moz-do-not-send="true"
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><o:p></o:p></span></p>
          </div>
          <div>
            <p class="MsoNormal"><span
                style="font-family:"Arial",sans-serif;color:black"><o:p> </o:p></span></p>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
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>