I know this answer must be out there, but I can\'t figure out how to word the question.
I\'d like to calculate the differences between values in my data.frame.
If year column isn't sorted then you could use match:
year
match
f$diff <- f$value - f$value[match(f$year-1, f$year)]