The proper way to codify Na in a list in R
-
01-11-2019 - |
Question
I am trying to impute missing timeseries present in different dimentions, row by row, on the whole date set. I showed the type of return of na.kalman()
and it happens to be a tribble, I am not so keen on R, so I thought converting it to a plain vector will do it, something like array(as.data.frame(imputed_slice))
library("imputeTS")
library(readr)
slice <- read_csv("slice.csv")
little_slice <- slice[c(750: 850)]
for (row in 1:nrow(little_slice)) {
ts <- little_slice[row,]
if(any(is.na(ts)))
{
imputed_ts <- na.kalman(ts, model = "auto.arima")
little_slice[row,] <- array(imputed_ts)
}
}
#529, 811, 812 missings
Looking for warning, I see something like:
imputeTS: No imputation performed for column 64 because of this Error in na.kalman(data[, i], model, smooth, nit, ...): Input data needs at least 3 non-NA data point for applying na.kalman
For every row, so I tried to force other columns to be NA
Like this:
slice$`811` <- NA
slice$`812` <- NA
slice$`822` <- NA
slice$`832` <- NA
To sum up, why na.kalman() not recognizing my NAs?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange