I have a data frame in R that includes city names, years, and months. It looks like the following:
Sample data set with Month, Year, and City columns
This table continues for thousands of records. Some cities do not have data for every month in the year (e.g. the 1920 data for Los Angeles in the example above only contains January and February), meaning they are incomplete. I want to extract out only those years which are complete for a given city (e.g. contains all 12 months for that year, like Toronto in the above example).
I have tried converting it into the zoo::yearmon class, but I do not know how to manipulate it to do what I have described above. I believe that a script could be written that looks at the year and city name, checks if it contains all 12 months, and then omits years that do not.