I am working through the following tutorial about how to create clusters within a dataset. The tutorial can be found here.
Using the following code, we can create a plot where we visualise the three clusters which have been formed.
library(factoextra)
library(cluster)
library(NbClust)
#
data(iris)
head(iris)
#
iris.scaled <- scale(iris[, -5])
head(iris.scaled)
#
# K-means clustering
set.seed(123)
km.res <- kmeans(iris.scaled, 3, nstart = 25)
#
# lets inspect the output here
kmeans(iris.scaled, 3, nstart = 25)
#
#
# k-means group number of each observation
km.res$cluster
#
# Visualize k-means clusters
fviz_cluster(km.res, data = iris.scaled, geom = "point",
stand = FALSE, frame.type = "norm") + theme_bw()
While, it looks fantastic that we have found three clusters within the dataset, I cannot understand what we have plotted on our x and y axis, what is the Dim1 and Dim2 and what does the 73 and 22.9% have to do with anything.
We plot the output from the kmeans
command, where I assume it calls upon the Cluster means:
??