multiedit(x, class, k=1, V=3, I=5, trace=T)
P. A. Devijver and J. Kittler (1982) Pattern Recognition. A Statistical Approach. Prentice-Hall, p. 115.
set.seed(99) tr <- sample(1:50,25) train <- rbind(iris[tr,,1],iris[tr,,2],iris[tr,,3]) test <- rbind(iris[-tr,,1],iris[-tr,,2],iris[-tr,,3]) cl <- factor(c(rep(1,25),rep(2,25), rep(3,25)), labels=c("s", "c", "v")) table(cl, knn(train, test, cl, 3)) ind1 <- multiedit(train, cl, 3) length(ind1) table(cl, knn(train[ind1, , drop=F], test, cl[ind1], 1)) ntrain <- train[ind1,]; ncl <- cl[ind1] ind2 <- condense(ntrain, ncl) length(ind2) table(cl, knn(ntrain[ind2, , drop=F], test, ncl[ind2], 1))