Given a data frame where each observation in a column is a string of the form "x~y" where x and y are integers.
The goal is to transform the "x~y" string into a vector, c(x..y) which is a sequence of numbers that start with integer x and end with integer y.
Finally, the data frame needs to be unnested so that each element of the vector gets its own row and the other columns are properly repeated.
For example, here's a data frame:
A B
A1 -1~1
A2 1~3
A3 2~4
The above data frame should be changed to the following:
A B
A1 -1
A1 0
A1 1
A2 1
A2 2
A2 3
A3 2
A3 3
A3 4
It is impossible to set the str_replace examples as there are lots of cases.. How do I make this code??