I am using k-means clustering using R and I divide the data set with two clusters
clus.data <- df[,1:14]
head(clus.data)
heart.cluster <- kmeans(clus.data,2)
how to plot the graph with cluster to view them?
One thing I should point out is that you should scale your data set before k-means as a form of standardisation of the data (if you haven't scaled it already that is!):-
clus.data <- df[,1:14]
head(clus.data)
scaledData<-scale(clus.data)
heart.cluster <- kmeans(scaledData,2)
You could use the factoextra
package.
library(factoextra) # clustering algorithms & visualization
And to visualise:
fviz_cluster(heart.cluster, data = scaledData)