I have the following dataset:
Class Range Value
A 6 - 8 19
B 1 - 3 14
C 5 - 16 10
D 4 - 7 5
I want to split the range for each class into two columns. To do that, I used the function str_split_fixed
as the following:
merge(data, str_split_fixed(data[, 2], " - ", 2))
and I even tried:
merge(data, str_split_fixed(data$Range, " - ", 2))
But both of them give me the following results:
Class Range Value V1 V2
A 6 - 8 19 6 8
B 1 - 3 14 6 8
C 5 - 16 10 6 8
D 4 - 7 5 6 8
My question is, why does it repeat the first range for the rest of the classes? Can someone help?