title: How to duplicate a row based on the presence of multiple values in a column in R
body: <p>I have a dataframe with phonetic transcriptions of words called <code>trans</code>, and a column <code>pos_num</code>which records the position of the phoneme <code>t</code>in the transcription strings.</p>
  <pre><code>df &lt;- data.frame(
    trans = c(&quot;ðət&quot;, &quot;əˈpærəntli&quot;, &quot;ˈkɒntrækt&quot;, &quot;təˈwɔːdz&quot;, &quot;pəˈteɪtəʊz&quot;), stringsAsFactors = F
  )
  df$pos_num &lt;- sapply(strsplit(df$trans, &quot;&quot;), function(x) which(grepl(&quot;t&quot;, x)))
  
  df
         trans pos_num
  1        ðət       3
  2 əˈpærəntli       8
  3  ˈkɒntrækt    5, 9
  4   təˈwɔːdz       1
  5 pəˈteɪtəʊz    4, 7
  </code></pre>
  <p>In some transcriptions, <code>t</code> occurs more than once, resulting in multiple values in <code>pos_num</code>. Where this is the case I would like to duplicate the entire row, with the original row containing one value and the duplicated row containing the other value. The desired output would be:</p>
  <pre><code>df
         trans pos_num
  1        ðət       3
  2 əˈpærəntli       8
  3  ˈkɒntrækt       5
  4  ˈkɒntrækt       9
  5   təˈwɔːdz       1
  6 pəˈteɪtəʊz       4
  7 pəˈteɪtəʊz       7
  </code></pre>
  <p>How can this be achieved? (There seem to be a few posts on that question for other programming languages but not R.)</p>