I have a time series of daily precipitation values starting in 1838 and finishing in 2001. There are some missing days in the record that are coded with an NA. My data takes the form:
Year Month Day PPT
1838 1 1 0.0
1838 1 2 NA
1838 1 3 1.3
1838 1 4 0.6
I am now using an aggregate function to sum the daily precipitation totals into monthly means per year of the record using:
aggregate(PPT~Year, df, sum)
This works fine, but the problem is that some of the monthly aggregated sums are not genuine. For example, if there were 20 missing days in the month of January 1838 then the aggregated sum for that month would not be genuine.
What I want to do is for my aggregate function not to return aggregated sums for any months containing missing days (NA), i.e. if even just 1 day is missing I want the month not to be returned. Alternatively I could remove any months containing any NA values before aggregating.