I have a data frame like this:
v2 v3
1.000 2:3,3:2,5:2,
2.012 1:5,2:4,6:3,
The second column v3, consists of 'index-value' pairs, each pair separated by a ,
.
Within each 'index-value' pair, the number preceeding the :
is the vector index. The number after the :
is the corresponding value. E.g. in the first row, the vector indices are 2, 3, and 5, and the corresponding values are 3, 2, and 2.
Indices not represented in the string should have the value 0 in the resulting vector.
I wish to convert the 'index-value' vector to a vector of values.
Thus, for the two strings above the expected result is:
v2 v3
1.000 c(0,3,2,0,2,0)
2.012 c(5,4,0,0,0,3)