Perform the following steps to cut the hierarchy of clusters into a given number of clusters:
- First, categorize the data into four groups:
fit = cutree(hc, k = 4)
- Then count the number of data within each cluster:
- Finally, visualize how the data is clustered with the red rectangle border:
plot(hc)rect.hclust(hc, k = 4 , border="red"
Here is the visualization with the red rectangle border: