October 2017
Beginner to intermediate
572 pages
26h 1m
English
We can determine the number of clusters from the dendrogram in the preceding figure. In this recipe, we determine that there should be four clusters within the tree. Therefore, we specify the number of clusters as 4 in the cutree function. Besides using the number of clusters to cut the tree, you can specify the height as the cut tree parameter.
Next, we can output the cluster labels of the data and use the table function to count the amount of data within each cluster. From the counting table, we find that most of the data is in cluster 4. Lastly, we can draw red rectangles around the clusters to show how data is categorized into the four clusters with the rect.hclust function.
Read now
Unlock full access