A subset of winter (Dez, Jan, Feb) from daily time series (zoo)

I have a daily zoo (xts) with several decades of data in the following format:

head(almorol)
1973-10-02 1973-10-03 1973-10-04 1973-10-05 1973-10-06 1973-10-07
     183.9      208.2      153.7       84.8       52.5       35.5

and I would like to compile only winter data (full months of December, January and February). I found a subset for xts, so I thought I could extract all the Decamers using:

x<-apply.yearly(almorol, FUN=last(almorol, "1 month"))

and then do something similar to January and February, but I get the following error:

Error in get(as.character(FUN), mode = "function", envir = envir) :
object 'FUN' of mode 'function' was not found

I can use apply.yearlyit last(almorol, "1 month")separately, but when I combine them, it does not work. Does anyone know a way to subset these three months of a time series? Thanks for the help!

+3
source share
1 answer

Try the following:

z.winter <- z[months(time(z), TRUE) %in% c("Dec", "Jan", "Feb")]
plot(z.winter)
+6
source