| autoplot.knnForecast | R Documentation |
It uses a knnForecast object to create a ggplot object that plots a time series and its forecast using KNN regression.
## S3 method for class 'knnForecast'
autoplot(object, ...)
object |
An object of class |
... |
additional parameter, see details. |
Commonly used parameters are:
highlight. A character string indicating what elements should be highlighted. Possible values are
"none", "points" and "neighbors". The default value is "none".
faceting. Logical. This applies only if the highlight parameter is
set to "neighbors". It indicates whether the different nearest neighbors
should be seen in different plots (TRUE, the default value) or in one
plot.
The ggplot object representing a plotting with the forecast.
pred <- knn_forecasting(USAccDeaths, h = 12, lags = 1:12, k = 2)
library(ggplot2)
autoplot(pred)
autoplot(pred, highlight = "neighbors")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.