I have a dataset where observations are ID year event_type event_date. There are an unbalanced number of observations per ID year. To be specific these are battle-outcomes within conflict-years. Each battle has a date and a type(outcome).
What I want to do is create a variable based on the number of events of a certain type within the subset of ID year. So:
by ID
by year
sum of event_type == x
I understand how to do this with a regular for loop, but I understand I should use tapply() since I have different numbers of observations per ID?
If I understand the question correctly, then: