我尝试caret
并DMwR
进行插补。他们都给出错误
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')
谢谢!
dat
数据框中没有Y
列。您可以改用:
impu = preProcess(dat, method = c('knnImpute'))
dat1 = predict(impu, newdata = dat)