Question

I have a daily zoo (xts) with a few 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 plot just winter data (the full months of December, January and February). I found the subsetting for xts so I thought I could extract all the Decembers using:

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

and then do something similar for Jan and Feb, 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 the apply.yearly and last(almorol, "1 month") separately but when I combine them it doesn't work. Does anyone know a way of subsetting those 3 months of the time series? Thanks for helping!

Was it helpful?

Solution

Try this:

z.winter <- z[months(time(z), TRUE) %in% c("Dec", "Jan", "Feb")]
plot(z.winter)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top