I have an entry with commas. How to split into separate rows?
<p>I have a dataframe similar to below</p>

<pre><code>df &lt;- data.frame(var1=c('apple, bob, cat', 'b', 'c'), var2=c('d', 'e', 'f'))
df
             var1 var2
1 apple, bob, cat    d
2               b    e
3               c    f
</code></pre>

<p>I'm needing to split var1$1 into:</p>

<pre><code>   var1 var2
1 apple    d
2   bob    d
3   cat    d
4     b    e
5     c    f
</code></pre>

<p>Such that var2 is duplicated.. I know how I can duplicate rows but am unsure if a nice way to split var1$1 into 3 rows. My df actually has many rows where similar to the "apple, bob, cat" issue above with as many as 20 different terms!</p>