I have the following random (shortened) dataset with dates and quintile:
| Date | Quintile |
|---|---|
| 05/03/2021 | 5 |
| 05/03/2021 | 3 |
| 05/03/2021 | 1 |
| 04/03/2021 | 2 |
| 04/03/2021 | 4 |
| 03/03/2021 | 4 |
| 03/03/2021 | 1 |
| 03/03/2021 | 2 |
I would like to reshape the dataframe as follows:
| Date | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| 05/03/2021 | 1 | 0 | 1 | 0 | 1 |
| 04/03/2021 | 0 | 1 | 0 | 1 | 0 |
| 03/03/2021 | 1 | 1 | 0 | 0 | 1 |
The new data frame will be aggregated by date, with the individual quintiles the new columns. I've explored the dplyr functions but I can't quite get it right :(
I set the Quintile values 'as.character' but I'm not sure where I am going wrong.



