I'm using a survey dataset (ESS) that includes several countries per wave, and several individuals within each wave. It looks something like this:
Country | Wave |
---|---|
AT | 1 |
AT | 1 |
AT | 1 |
AT | 2 |
AT | 3 |
AT | 3 |
AT | 4 |
AT | 4 |
AT | 5 |
AT | 6 |
AT | 7 |
AT | 8 |
AT | 9 |
AT | 9 |
BE | 1 |
BE | 2 |
BE | 2 |
BE | 3 |
BE | 4 |
BE | 5 |
BE | 6 |
BE | 7 |
BE | 7 |
BE | 9 |
BE | 9 |
I would like to filter/subset the data to get a new clean dataframe that includes only countries that are included in all of the waves, which range from 1 to 9. In other words, I would need to select countries based on the condition that they have observations in all 9 waves. In the example above, only "AT" would be selected as "BE" is missing wave #8.
This sounds rather straightforward but I am struggling to find a simple way to go about it (likely due to the fact that I am new in R).
Many thanks for your help.
Aucun commentaire:
Enregistrer un commentaire