对齐多个 xts 时间序列图
我有一个包含 4 列的 xts 对象。前 3 列是比例的平均值以及置信下限和上限。第 4 列是样本大小。由于比例不同,我认为将前 3 列绘制在一个图表上,并将第四列绘制在其正下方的单独图表上是有意义的。关于如何执行此操作有什么建议吗?
下面是构建一个 xts 对象的代码,该对象与我拥有的对象类似:
startTime = Sys.time()
n = 10
d = seq(startTime,startTime+n*24*60*60,by="1 day")
a = sample(10000,length(d),replace=TRUE)
p = runif(length(d))
l = p/2
u = p+(p+1)/2
x= xts(p,d)
x = cbind(x,l,u,a)
colnames(x) = c("prop","low","high","size")
I have an xts object with 4 columns. The first 3 columns are the mean and lower and upper confidence bounds for a proportion. The 4th column is the sample size. Since the scales are different, I thought it would make sense to plot the first 3 columns on one graph, and plot the 4th on a separate graph, right below it. Any suggestions on how to do this?
Here's code to build an xts object that's like the one I have:
startTime = Sys.time()
n = 10
d = seq(startTime,startTime+n*24*60*60,by="1 day")
a = sample(10000,length(d),replace=TRUE)
p = runif(length(d))
l = p/2
u = p+(p+1)/2
x= xts(p,d)
x = cbind(x,l,u,a)
colnames(x) = c("prop","low","high","size")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用plot.zoo,这很容易做到。像这样的东西将帮助您开始:
?plot.zoo
中有大量示例;请务必检查一下。It's easy to do if you use
plot.zoo
. Something like this will get you started:There are tons of examples in
?plot.zoo
; make sure to check them out.