?autoplot.forecast
If showgap=FALSE, the gap between the historical observations and the forecasts is removed.
但是,對我來說它沒有被洗掉。
library(forecast)
d <- ts(rnorm(36), start = c(2021, 1), frequency = 12)
fc <- snaive(d, h = 12)
autoplot(fc, showgap = FALSE)
plot但是使用效果很好
plot(fc, showgap = FALSE)
uj5u.com熱心網友回復:
OP,我原本以為這是forecast::autoplot()函式中的錯誤,但事實證明并非如此。在物件上plot.forecast()使用時運行的函式包含引數。該命令確實指示引數,但不是用于- 它用于函式。plot()'forecast'showgap=?autoplot.forecastshowgap=autoplot()plot.forecast()
好訊息是,似乎有一個autolayer(...)包含此引數的方法,您可以使用它。即再次檢查幫助plot.forecast()有點低,你會看到這個:
## S3 method for class 'forecast'
autolayer(object, series = NULL, PI = TRUE, showgap = TRUE, ...)
我們可以autolayer()與autoplot(). 所以,這似乎有效:
autoplot(fc) autolayer(fc, showgap = F)

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/315897.html
