K-Means Clustering code from scratch using R programming language.
ggplot2
for plotting the clustering result in each iteration
There are 2 sample dataset in this project, they are dataset 1 and dataset 2.
Each dataset consist of N rows data and 2 columns represent the x-axis and and y-axis.
The code is designed to cluster dataset 2 into 3 clusters. If you want to change either dataset or the final number of clusters on another dataset samples, change the following parameters:
Change the following code in line 5 into desired dataset filename.
test1_data <- read.table("D:/test2_data.txt", quote="\"", comment.char="")
Change the following code in line 10-12 into desired number of clusters.
cluster <- 3
c_initial <- c(0,1,2)