I have a set of 10 years of contribution data in R. The dollar values are grouped by ID# (of the person giving the gift) and year given. There is not a gift for every person in every year. For each row, I want to indicate if the row (gift) is the first contribution (never before given), if it is the same as the prior year, greater than the prior year, less than the prior year, if there was no gift in the prior year (but there was a gift in some previous year). In addition, I want to indicate if the person giving this gift did not give a gift in the NEXT year.
So, if the data looks like this:
ID# YEAR GIFT
1 2005 $10
1 2006 $5
1 2008 $15
1 2009 $20
1 2010 $20
the result should be:
ID# YEAR GIFT STATUS
1 2005 $10 FIRST
1 2006 $5 LOWER also NO NEXT YEAR
1 2008 $15 PREVIOUS GIVER
1 2009 $20 HIGHER
1 2010 $20 SAME
Thanks!