r - 如何在 Rstudio 中组合两个时间序列?
问题描述
代码:
times_USST <- ts(Final_Com_return$Comp.int_USST, start= 1934-01, frequency = 12)
times_TRSB <- ts(Final_Com_return$Comp.int_TRSB, start= 1934-01, frequency= 12)
这两行代码组成了两个独立的情节。我的问题是将两者结合起来。我们正在尝试为股票指数和我们的国库券制作线性和对数比例图
解决方案
我认为这个帖子。会帮助你。正如Pete Baker所述, “您可以使用 xts 包来为您处理细节(例如,即使该系列有间隙)”
library(xts)
ts1<-as.xts(ts(c(1:12),star=c(2014,1),freq=12))
ts2<-as.xts(ts(c(13:24),star=c(2015,1),freq=12))
str(ts3 <- c(ts1, ts2))
# An ‘xts’ object on Jan 2014/Dec 2015 containing:
# Data: int [1:24, 1] 1 2 3 4 5 6 7 8 9 10 ...
# Indexed by objects of class: [yearmon] TZ:
# xts Attributes:
# NULL
推荐阅读
- html - 当按钮设置在侧边栏中并使用位置显示在侧边栏外时,如何管理按钮和模式弹出?
- javascript - 我正在从刀片模板传递一个数组“插槽”,并希望在 js 文件中获取它的值,例如 name=slot['name'];
- javascript - 使用 apache 别名的服务工作者不起作用
- python - pandas - 从列中提取大于阈值的值
- reactjs - 垂直滚动 Material UI 表体
- angular - 如何为 Angular 禁用 tslint 错误 Visual Studio?
- mysql - Hybris 18.08 - B2C 安装的 MySQL db 错误
- python - [-4:] 在 python 中是什么意思?
- python - scrapy-redis如何实现第一个请求为post请求
- performance - Jmeter主从连接超时错误