I have a dataframe such as below, and i want to many hot this based on week,
id week
345 1
351 2
222 4
264 3
345 5
277 2
345 2
345 2
264 5
...
this is my ideal output:
id week1 week2 week3 week4 week5
345 1 2 0 0 1
351 0 1 0 0 0
222 0 0 0 1 0
264 0 0 1 0 1
277 0 1 0 0 0
...
and my idea for this problem was based on combining one hot encoded of this dataframe, but it was very complex,
any body knows can i get this output in R?