I have a data set where each row contains the accumulated number of offspring of a female each year. Some individuals die from one year to the next.
Year ID Sex AccumulatedFecundity
1 2411 female 29
1 583 female 30
1 469 female 147
2 2290 female 161
2 583 female 169
2 788 female 27
I would like to undo this accumulation and get the raw values. In my example the second appearance of female 583 should get a raw value of 139 (169-30).