I have created a time series model using package forecast
and have plotted the observations and forecast values using 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)
However, I am looking to label the observations like so:
Variable label position in ggplot line chart but only for the forecast values. I understand the clause ought to be geom_text( aes(label = ?) )
but since the object y
being passed onto autoplot
is a ts
I am unsure as to how to reference ?
I have resorted to as.numeric(y[["mean"]])
but got the error Error: geom_text requires the following missing aesthetics: x, y
since this is a vector and dates are missing?
Thank you.