title: R: Splitting up strings "pairwise" into a variable number of elements
body: <p>My goal is to plot the structure of a questionnaire.
  For every respondent I have a value giving the question answered plus the answer time:
  <code>q1:2,q2:3,q4:4,q10:4</code> means that the corresponding respondent answered question <code>q1</code> first (in 2 seconds), then he answered <code>q2</code> (in 3 seconds) and so forth until question <code>q10</code>. Sometimes the names of the questions also start with &quot;d&quot; (e.g. <code>d10</code>) which is just another type of question.</p>
  <p>Example:</p>
  <pre><code>dat &lt;- data.frame(path = c(
    &quot;q1:9,q2:8,d3:10,q10:3,q4:10&quot;,
    &quot;q1:10,q2:10,q10:2,q4:2&quot;,
    &quot;q1:2,q2:3,d11:2&quot;
  ))
  </code></pre>
  <p>My idea is to plot the structure of how the questionnaire was answered as a network-graph. So I need a long list of all  the different &quot;steps&quot; the respondents made within the questionnaire:</p>
  <pre><code>from | to
  ------------
  q1     q2 # first respondent
  q2     d3
  d3     q10
  q10    q4
  q1     q2 # second respondent
  q2     q10
  q10    q4
  q1     q2 # third respondent
  q2     d11
  ...
  </code></pre>
  <p>My problem is that due to filter-questions not all the respondents had to answer the same number of questions (so I can't use <code>separate(, into=?)</code> because ? is variable). Furthermore the variables need to be split up &quot;pairwise&quot;.</p>
  <p>Does someone have an idea how to get the above dataframe??</p>
  <p>The final goal would, of course, be to have a table including the number of respondents for each &quot;step&quot; (e.g. 20 respondents went from <code>q1</code> to <code>q2</code>, so 20 can be used as a weighting variable in the graph).</p>
  <p>Thanks!</p>