I have a mini data frame
index | data | district | month |
---|---|---|---|
1 | data1 | District-1 | month1 |
2 | data2 | District-2 | month2 |
and so on
I want to load the data values from the data column to the data frame which has a structure like:-
month1 | month2 | |
---|---|---|
District-1 | data1 | NA |
District-2 | NA | data2 |
and so on
In short, the data1 from the mini data frame should go to its perfect cell in the big data frame where the district and months are matching. All the cells of big data frame are filled with null.
You don't have
District-2
in your original data (though it appears in your desired data), but generally if you wanted this, try usingtidyr::pivot_wider()
:Output