rep <- system.file("extdata", package="RclusTool")
featuresFile <- file.path(rep, "sample_example_features.csv")
features <- read.csv(featuresFile, header = TRUE)
features$ID <- NULL
traindir <- file.path(rep, "train_example")
tf <- tempfile()
write.table(features, tf, sep=",", dec=".")
x <- importSample(file.features=tf, dir.save=dirname(tf))
train <- readTrainSet(traindir)
res <- computeSupervised(x, prototypes=train)
plot(features[,3], features[,4], type = "p", xlab = "x", ylab = "y",
col = res$label, main = "K-Nearest-Neighbor classification")
Run the code above in your browser using DataLab