If I might ask, going back to another question I had posted before, I've realized that by converting my data into wide format I complicate things. Let's say you have the same data structure in the long format. But now we also need to get the cumulative number of people who had an incident up until every age. The tricky part is that once a person has an incident and it is accounted for, if this person has incidents after that, it doesn't contribute to increasing the count anymore. Let's say for ID3 it presents an incident at age 1, 3 and 48. But this person can only contributes to the count at age 1. And also, if they have more than one incident at the same age, it counts as 1. The output should look like this: Age Cumulative 0 2 3 2 22 3 48 3 76 3 131 3
... View more