I have a CSV that I need to clean up / organize in a usable way using R. I need to group by the property ID and then want to take all the unique years for the defor year column and make each year into a sperate column with the amount of deforestation for that year. My data frame / CSV looks like this:
Prop_ID deforYear deforHA
1 2010 15
1 2011 0
1 2012 10
2 2010 35
2 2011 45
2 2012 0
and I want the output to look like this:
Prop_ID defor_2010 defor_2011 defor_2012
1 15 0 10
2 35 45 0
I'm assuming I use the group_by function in dplyr but I can't seem to figure it out.