I want to reshape my data which is in the following form in dataframe :
a b Type_c d e
1 1 0 10 9
2 1 0 20 9
3 2 1 30 4
4 2 2 40 3
5 3 3 50 2
6 3 0 60 1
7 4 3 70 2
8 4 2 80 7
9 4 2 90 8
And would like to get the data in the following format by reshaping or transforming.
a b Type_0_d Type_0_e Type_1_d Type_1_e type_2_d type_2_e type_3_d type_3_e
1 1 10 9 0 0 0 0 0 0
2 1 20 9 0 0 0 0 0 0
3 2 0 0 30 4 0 0 0 0
4 2 0 0 0 0 40 3 0 0
5 3 0 0 0 0 0 0 50 2
6 3 60 1 0 0 0 0 0 0
7 4 0 0 0 0 0 0 70 2
8 4 0 0 0 0 80 7 0 0
9 4 0 0 0 0 90 8 0 0
I found it little difficult to do the same in R. However, in Tableau it was just straight forward. Just wanted to know if there's a way to do the same in R effectively.