R - accuracy() and “Error in xx - ff[1:n] : non-numeric argument to binary operator”

I’m new to time series. While building a basic predictive model using the dowjones data set from library(fma) I ran into “> Error in xx - ff[1:n] : non-numeric argument to binary operator”.

library(forecast)
library(fma)

dj60 <- window(dowjones, end = 60)

dj60.rwf.drift <- rwf(dj60, h = 18, drift = TRUE)

dj60.od <- window(dowjones, start = 61)

accuracy(dj60.od, dj60.rwf.drift)

Returns:

Error in xx - ff[1:n] : non-numeric argument to binary operator

The preceding chain of commands works for another data set (visnights from the fpp2 library):

library(forecast)
library(fpp2)

vn_Melbourne_train1 <- window(visnights[, "QLDMetro"], end = c(2014, 4))

snaive_vn_Melbourne_train1 <- snaive(vn_Melbourne_train1, h = 4)

vn_Melbourne_test1 <- window(visnights[, "QLDMetro"], start = c(2015, 1), end = c(2015, 4))

accuracy(snaive_vn_Melbourne_train1, vn_Melbourne_test1)

I have str() ed all of the objects and find them comparable.

Why does this error occur for one data set and not the other?

© Copyright 2013-2021 Analytics Vidhya