I have a data structure like:
X1 X2 X3
AA x1;y1 100
BB 200
CC x3;y3;z3 300
DD x4;y4 400
Reproducible data
df <- data.frame(
X1 = c("AA", "BB", "CC", "DD"),
X2 = c("x1;y1", "", "x3,y3,z3", "x4;y4"),
X3 = c("100", "200", "300", "400")
)
How can i distribute second column to first column as distribute. output:
Xf X3
AA 100
x1 100
y1 100
BB 200
CC 300
x3 300
y3 300
z3 300
DD 400
x4 400
y4 400
Thanks.