I have a dataframe similar to below
df <- 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
I'm needing to split var1$1 into:
var1 var2
1 apple d
2 bob d
3 cat d
4 b e
5 c f
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!