KNN <-
function(train,test,g,k=1,prob=TRUE,use.all=TRUE){
#
# Do classification using the kNN method
#
#
# train is the training set
# test is the test data
# g contains labels for the data in the training set,
#
# This function removes the need to call library class.
# For more information, use the command ?knn
#
library(class)
res=knn(train,test,cl=as.factor(g),k=k,prob=prob)
res
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.