Error in knn(train = iris_train, test = iris_test, c1 = iris_train_target, : unused argument (c1 = iris_train_target)

knn
r

#1

I am working on knn algorthim in R on the iris data set while creating the model I am getting the error
my code is
data(iris)
str(iris)
set.seed(9850)
gp<-runif(nrow(iris))
iris<-iris[order(gp),]
normalize<-function(x){
return((x-min(x))/(max(x)-min(x)))}
irisn<-as.data.frame(lapply(iris[,c(1,2,3,4)],normalize))
iris_train<-irisn[1:129,]
iris_test<-irisn[130:150,]
iris_train_target<-iris[1:129,5]
iris_test_target<-iris[130:150,5]
require(class)
m1<-knn(train=iris_train, test=iris_test, c1=iris_train_target, k=13)

at m1 I am getting the error
Error in knn(train = iris_train, test = iris_test, c1 = iris_train_target, :
unused argument (c1 = iris_train_target)


#2

There is a small typo error you are making,
In the following code :
m1<-knn(train=iris_train, test=iris_test, c1=iris_train_target, k=13)

its cl not c1 , ā€˜lā€™ instead of 1. Basically cl stands for classification. It should work now.

This one works
m1<-knn(train=iris_train, test=iris_test, cl=iris_train_target, k=13)