title: separate rows based on delim based on two columns in r
body: <p>I have the following df:</p>
  <pre><code>df_1=data.frame(col_1=c(&quot;a;b;c&quot;,&quot;c;d&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;h;j&quot;),col_2=c(&quot;1;2;3&quot;,&quot;4&quot;,&quot;5;6&quot;,&quot;7&quot;,&quot;8;9&quot;,&quot;10;11;12&quot;))
  </code></pre>
  <p>so I want to separate col_1 into separate rows with corresponding values of col_2 if it exists.</p>
  <ol>
  <li><p>For example if number of elements in col_1= number of elements in col_2 then they should be separated with their corresponding values in col_1 and col_2 ( row 1)</p>
  </li>
  <li><p>if they have differing number of elements, if one column has only has one element, then that can be separated to different rows as well (row 2)</p>
  </li>
  <li><p>if they have disproportionate number of elements ( more than 1 each and not equal) then it should be left as-is</p>
  </li>
  </ol>
  <p>here is the final_dataset:</p>
  <pre><code>df_2=data.frame(col_1=c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;,&quot;e&quot;,&quot;f&quot;,&quot;g&quot;,&quot;g&quot;,&quot;h;j&quot;),col_2=c(&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;,&quot;10;11;12&quot;))
  </code></pre>