rforecast

R. Forecast time series with R. Cannot plot autolayer


I am doing a forecast analysis and I would like to plot the training and testing set on a plot. Here is my code:

library(forecast)
train <- head(AirPassengers, round(length(AirPassengers) * 0.6))
h <- length(AirPassengers) - length(train)
test <- tail(AirPassengers, h)

autoplot(train) + autolayer(test)
**Error: Invalid input: date_trans works with objects of class Date only**

What Am I doing wrong? When I use str() to check both train and test it says they are both Time-Series...

Any help is appreciated.


Solution

  • Following Edo's suggestion I realised that the problem is due to some package conflict.