已安装软件包,但出现无法找到功能的错误R [英] Installed package, but getting an error that function can't be found R
问题描述
可能重复:
错误:找不到函数…在R
Possible Duplicate:
Error: could not find function … in R
我正在尝试在R中使用knn函数,并已安装了多个软件包(例如KNN,KNNgarden,iped).
I am trying to use knn function in R and have installed several packages to do so (eg. KNN, KNNgarden, iped).
使用R-Studio时,会成功安装该软件包(成功解压缩了软件包"kknn"并检查了MD5的总和),但是当我尝试使用kknn时(kknn(train,test,cl,k = 1,l = 0,概率= TRUE,use.all = TRUE)),我收到以下错误消息:错误:找不到函数"kknn"
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"
我假设这与我的工作目录有关.我检查并将WD重置为R中具有软件包的文件夹,但知道没有用.我在做什么错了?
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?
推荐答案
除了安装软件包外,还必须加载它们.一次需要安装,每次启动新的R会话时都需要加载.这些都可以解决问题.
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)
这篇关于已安装软件包,但出现无法找到功能的错误R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!