Installed package, but getting an error that function can't be found R [duplicate]

若如初见. 提交于 2019-12-02 08:59:41

问题


Possible Duplicate:
Error: could not find function … in R

I am trying to use knn function in R and have installed several packages to do so (eg. KNN, KNNgarden, iped).

Using R-Studio, it comes across as thepackage is successfully installed (package ‘kknn’ successfully unpacked and MD5 sums checked), but when I try to use kknn (kknn(train, test, cl, k = 1, l = 0, prob = TRUE, use.all = TRUE)) I get the following error: Error: could not find function "kknn"

I'm assuming this has something to do with my working directory. I checked and reset my WD to be the folder in R that has the packages, but to know avail. What am I doing wrong?


回答1:


In addition to installing packages, you must also load them. Installing is required once, loading is necessary every time you start a new R session. Either of these will do the trick.

require(kknn)
library(kknn)


来源:https://stackoverflow.com/questions/11584922/installed-package-but-getting-an-error-that-function-cant-be-found-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!