2018-10-25
阅读量:
786
如何提取时间序列中的数据
如题,怎么从时间序列中提取出同年不同月的数据啊呢?
要是想合并的话不如一开始就用matrix
sales <- c(18, 33, 41, 7, 34, 35, 24, 25, 24, 21, 25, 20,
22, 31, 40, 29, 25, 21, 22, 54, 31, 25, 26, 35)
data=matrix(sales,nrow=12)
dimnames(data) = list(c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),c(2003,2004))
data
如果一定要先ts的话:
data=tsales[cycle(tsales)==1]
for(i in 2:12){
data=rbind(data,tsales[cycle(tsales)==i])
}
dimnames(data) = list(c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),c(2003,2004))
data
0.0000
0
0
关注作者
收藏
评论(0)
发表评论
暂无数据
推荐帖子
0条评论
0条评论
1条评论