问题描述
我有一个每日动物园 (xts),其中包含以下格式的几十年数据:
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
我只想绘制冬季数据(12 月、1 月和 2 月的整个月份).我找到了 xts 的子集,所以我想我可以使用以下方法提取所有十二月:
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"))
然后对 Jan 和 Feb 执行类似的操作,但出现以下错误:
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
我可以单独使用 apply.yearly
和 last(almorol, "1 month")
但是当我将它们组合起来时它不起作用.有谁知道对这 3 个月的时间序列进行子集化的方法?感谢您的帮助!
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!
推荐答案
试试这个:
z.winter <- z[months(time(z), TRUE) %in% c("Dec", "Jan", "Feb")]
plot(z.winter)
这篇关于从每日时间序列(动物园)中提取冬季(Dez,Jan,Feb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!