I have a data frame like the below which contains commas in columns x & y:
df <- data.frame(var1=letters[1:5], var2=letters[6:10], var3=1:5, x=c('apple','orange,apple', 'grape','apple,orange,grape','cherry,peach'), y=c('wine', 'wine', 'juice', 'wine,beer,juice', 'beer,juice'))
df
  var1 var2 var3                  x               y
1    a    f    1              apple            wine
2    b    g    2       orange,apple            wine
3    c    h    3              grape           juice
4    d    i    4 apple,orange,grape wine,beer,juice
5    e    j    5       cherry,peach      beer,juice
What is the simplest way to get it to look like this:
dfnew                   
    var1    var2    var3    x       y
    a       f       1       apple   wine
    b       g       2       orange  wine
    b       g       2       apple   NA
    c       h       3       grape   juice
    d       i       4       apple   wine
    d       i       4       orange  beer
    d       i       4       grape   juice
    e       j       5       cherry  beer
    e       j       5       peach   juice
I have seen similar questions, however, while i am using 3 columns in my example, my real data has many. I need something that will take all the columns but x & y and replicate and then put the "," in tabular form like my desired outcome.