I'm trying to have R go through a loop within ID groups, and within each group:
- find the max year;
- count the number of prior observations (by year) that have a code other than the code corresponding to the current row;
- disregard observations that appear in the same year.
I would very...