r - 使用自动绘图标记值
问题描述
我使用包创建了一个时间序列模型forecast
,并使用autoplot
.
require(ggplot2)
require(forecast)
y <- hw(AirPassengers, h=10, seasonal="multiplicative")
autoplot(y, main="Air passengers - Holt seasonal") +
autolayer(y, series="multiplicative", PI=FALSE)
但是,我希望像这样标记观察结果:
ggplot 折线图中的变量标签位置,但仅用于预测值。我理解该子句应该是,geom_text( aes(label = ?) )
但是由于y
传递给的对象autoplot
是 ats
我不确定如何引用?
我已经诉诸as.numeric(y[["mean"]])
但得到了错误Error: geom_text requires the following missing aesthetics: x, y
,因为这是一个向量并且缺少日期?
谢谢你。
解决方案
推荐阅读
- c++ - c++:预期的主表达式
- flask - 来自烧瓶的数据的javascript函数
- c++ - 从树莓派读取的串口不稳定
- docker-compose - 在 docker swarm 中自动发现 Prometheus 指标端点
- java - JAVA 测试 java.lang.NoClassDefFoundError: org/junit/runner/manipulation/Filter
- google-sheets - 针对第三列测试两列中的空白的公式
- java - jsonschema2pojo是否支持xml格式,如果支持,可能是什么方式?
- javascript - React 中的计算器项目在计算表达式后按下数字时发生。添加所需的数字而不是添加
- javascript - Object.call() 和 Object.__proto__.call() 有什么区别?
- php - PHP - 仅当 URL 中存在变量时才允许访问页面