我尝试使用ggplot绘制预先计算的置信区间。
但是有一个问题:
library(ggplot2)
p = ggplot(rawHistoricValues,aes(x=date,y=cumsum(amount)))+geom_line(color = "steelblue")
p + geom_ribbon(data=predictions, aes(ymin=pct05, ymax=pct95)) + geom_ribbon(data=predictions, aes(ymin=pct25, ymax=pct75))
此代码导致错误:Objekt 'amount' not found
。奇怪的是,绘制历史数据的第一个命令确实使用amount
并且正确绘制它并且只有geom_ribbon
似乎有问题
这是数据集的一部分
date pct05 pct25 pct50 pct75 pct95 group
1 2009-07-01 4276.00 4276.00 4276.00 4276.00 4276.00 2010-01-01
2 2009-07-02 4076.00 4076.00 4076.00 4076.00 4076.00 2010-01-01
3 2009-07-03 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
4 2009-07-04 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
5 2009-07-05 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
6 2009-07-06 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
7 2009-07-07 4664.76 4664.76 4664.76 4664.76 4664.76 2010-01-01
8 2009-07-08 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
9 2009-07-09 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
10 2009-07-10 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
11 2009-07-11 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
12 2009-07-12 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
13 2009-07-13 4477.37 4477.37 4477.37 4477.37 4477.37 2010-01-01
14 2009-07-14 4477.37 4477.37 4477.37 4477.37 4477.37 2010-01-01
15 2009-07-15 4030.55 4030.55 4030.55 4030.55 4030.55 2010-01-01
16 2009-07-16 4030.55 4030.55 4030.55 4030.55 4030.55 2010-01-01
17 2009-07-17 4344.58 4344.58 4344.58 4344.58 4344.58 2010-01-01
18 2009-07-18 4344.58 4344.58 4344.58 4344.58 4344.58 2010-01-01
19 2009-07-19 4344.58 4344.58 4344.58 4344.58 4344.58 2010-01-01
20 2009-07-20 4335.68 4335.68 4335.68 4335.68 4335.68 2010-01-01