robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.11k stars 341 forks source link

tsclean "Error in approx(idx, x[idx], tt, rule = 2) : need at least two non-NA values to interpolate" error when no NA values are present #866

Closed thagzone closed 3 years ago

thagzone commented 3 years ago

The following code produces the error in the subject:

foo <- c(0.011033, 0.074117, 0.023965, 0.024718, 0.023735) 
forecast::tsclean(foo)

Even perturbing just one of the numbers by, say, 0.1, avoids the error. Strangely, the error also persists under affine transformations of the vector above (meaning you can add a constant to the entire vector and scale each value by the same constant and the error remains).

I'm running R 4.0.0 and the most development build of forecast (though the error occurred as well before I updated to the development build).

Any ideas? Thanks!

robjhyndman commented 3 years ago

Fixed in https://github.com/robjhyndman/forecast/commit/def8eb476cf7bf233671cfed317909e949e6c515