Looking for a way in R to create a data-frame from another data-frame where the values of Col A act as indices and each unique values in Col B become new columns in the new data-frame with values of Col C being the values in the new column.
Data-frame 1:
Col A | Col B | Col C |
---|---|---|
A | 2011 | 1 |
B | 2012 | 2 |
C | 2013 | 3 |
D | 2011 | 4 |
E | 2012 | 5 |
D | 2013 | 6 |
A | 2013 | 7 |
Result:
Col A | 2011 | 2012 | 2013 |
---|---|---|---|
A | 1 | 0 | 7 |
B | 0 | 2 | 0 |
C | 0 | 0 | 3 |
D | 4 | 0 | 6 |
E | 0 | 0 | 5 |