Sorry if the title is confusing, but hopefully this example is clear.
I have a dataframe like this:
> dput(dt1)
structure(list(Variable = c("Apple", "Orange"), Value = c("12, 5",
"15")), class = "data.frame", row.names = c(NA, -2L))
As you can see, the Value
column contains a comma in the first row. I would like to separate this, so that the final dataframe looks like this:
> dput(dt2)
structure(list(Variable = c("Apple", "Apple", "Orange"), Value = c(12L,
5L, 15L)), class = "data.frame", row.names = c(NA, -3L))
All other columns should duplicate any time we are separating the comma.