I don't think this particular problem has appeared on the forum before, but please point me in the right direction if it's a duplicated question!
I have the following dataset and would like to reshape it from long to wide.
ID variable value
1 number of students 1000
1 percentage on financial aid 28
1 acceptance rate 12
1 percentage on financial aid 35
2 number of students 2000
2 percentage on financial aid 1
2 percentage on financial aid 70
Note that the value percentage on financial aid
appears twice for each id. I would like to keep just the second occurrence when reshaping from long to wide, since the first occurrence is the rank of the school by the "financial aid" measure, whereas the second occurrence is the actual value.
The variable name percentage on financial aid
is exactly the same for both values, so I was wondering whether there's a way to tell R to overwrite the first occurrence with the second. Right now R seems to keep the first occurrence.