Search code examples
rinstallationpackageknn

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


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?


Solution

  • 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)