0

我尝试caretDMwR归责。他们都给出了错误

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'

数据具有数字、因子和逻辑列。

请在此处下载数据并加载,load('data2013.RData') 谢谢!

4

1 回答 1

0

您的数据框中没有Ydat。您可以改用:

impu = preProcess(dat, method = c('knnImpute'))
dat1 = predict(impu, newdata = dat)
于 2016-01-28T21:39:17.630 回答