Hello all,
I have a data frame (df) that looks like this:
month year label color value
1 1 2012 0. Not labelled #ffffff 1
2 1 2012 0. Not labelled #ffffff 1
3 2 2012 0. Wet #ffffff 1
4 3 2012 0. Wet #ffffff 1
5 4 2012 0. average #ffffff 1
6 5 2012 0. average #ffffff 1
...
94 7 2015 4. Dry #d7191c 1
95 6 2014 4. Dry #d7191c 1
96 8 2018 4. Dry #d7191c 1
With the following line I'm trying to spread my dataframe by the labels:
df <- spread(df, label, color)
But I get the following Error:
Error: Each row of output must be identified by a unique combination of keys.
Keys are shared for 2 rows:
* 1, 2
I dont understand the Error, and thus have no idea on how to fix it.
Could anyone explain me the Error and explain me how to fix it?
Thanks in advance