knn imputation中的错误[R] - 是否符合逻辑?

时间:2016-01-28 21:27:17

标签: r r-caret imputation

我尝试 public void OnUp (View view) {} caret进行估算。他们都给出了错误

DMwR

数据包含数字,因子和逻辑列。

请下载数据here并加载Y = 35 impu = preProcess(dat[, -Y], method = c('knnImpute')) dat1 = predict(impu, newdata = dat[, -Y]) # Error in `[.data.frame`(old, , non_missing_cols, drop = FALSE) : # undefined columns selected dat1 = knnImputation(dat, scale = T, meth='median') # Error in scale.default(xcomplete, dm[i, ], FALSE) : # length of 'center' must equal the number of columns of 'x' 谢谢!

1 个答案:

答案 0 :(得分:0)

Y数据框中没有dat列。您可以改为使用:

impu = preProcess(dat, method = c('knnImpute'))
dat1 = predict(impu, newdata = dat)