在R中找不到函数“ knnImputation”

时间:2019-10-05 13:45:37

标签: r knn

我遇到错误找不到函数“ knnImputation”

  • Rstudio版本:-版本1.2.1335
  • 已加载的软件包:- c(“ ggplot2”,“ corrgram”,“ DMwR”,“ usdm”,“插入符”,“ randomForest”,“ e1071”,   “ DataCombine”,“ doSNOW”,“ inTrees”,“ rpart.plot”,“ rpart”,“ MASS”,“ xgboost”,“ stats”)

1 个答案:

答案 0 :(得分:0)

我建议使用 VIM::kNN() 插补,因为包 DMwR 已从 CRAN 中删除:

https://cran.r-project.org/web/packages/DMwR/index.html

# using DMwR::knnImputation
df_mod <- DMwR::knnImputation(df, k = 7)

# VIM approximate equivalent to DMwR
# Note, for numFun you can substitute stats::weighted.mean, they perform similarly, though some differences on the margins I am not sure of
df_mod <- VIM::kNN(df, k = 7, numFun = laeken::weightedMean, weightDist = TRUE)

我在使用 DMwR::knnImputation 的某些情况下遇到了一些挑战,这似乎工作得很好。