抛出一个错误,说我没有指定原点-我认为原点是1970-01-01 00:00:00,所以我不需要指定。在同事编写代码之前,代码就可以工作了。如何更正此错误?下面是部分代码(如果有帮助,我也可以发布完整的脚本)
样本数据csv:
YEARMONTH,COUNT,ZONE,DOMAIN
2011-04-01 00:00:00,1786,City1,Domain1
2011-05-01 00:00:00,1762,City1,Domain1
2011-06-01 00:00:00,1932,City1,Domain1
错误消息:
as.POSIXct.numeric(index(dfplot))中的错误:必须提供“来源”
R代码(有关错误的红色代码,请评论#很好地绘制数据):
# Plot
######################################
#Merge Time Series and Export Data
dfplot <- merge(as.xts(InputDataTimeSeries), as.xts(pred$lower))
dfplot <- merge(dfplot, as.xts(pred$mean))
dfplot <- merge(dfplot, as.xts(pred$upper))
dfplot <- merge(dfplot, as.xts(pred$fitted))
names(dfplot)[1:7] <- c("actuals", "lower80", "lower95", "predicted", "upper80", "upper95", "fitted")
#Nicely Plot the Data
ggplot(dfplot, aes(x=as.POSIXct(index(dfplot)))) +
geom_line(aes(y=fitted), col='grey90', size = 2) +
geom_line(aes(y=predicted), col='orange', size= 1) +
geom_line(aes(y=actuals), col='orange', size= 1) +
geom_ribbon(aes(ymin=lower80,ymax=upper80),alpha=0.3, fill="orange") +
geom_ribbon(aes(ymin=lower95,ymax=upper95),alpha=0.1, fill="orange") +
theme_bw() +
geom_vline(xintercept=as.numeric(as.POSIXct(end(InputDataTimeSeries))), linetype="dashed", fill="gray40") +
labs(title=paste(pred$method, "80/95% PI Bands" ) , x="Time", y="Observed / Fitted") +
theme(plot.title = element_text(size=18, face="bold"))