1. Learn
  2. /
  3. Courses
  4. /
  5. Cluster Analysis in R

Connected

Exercise

Clusters based on height

In previous exercises, you have grouped your observations into clusters using a pre-defined number of clusters (k). In this exercise, you will leverage the visual representation of the dendrogram in order to group your observations into clusters using a maximum height (h), below which clusters form.

You will work the color_branches() function from the dendextend library in order to visually inspect the clusters that form at any height along the dendrogram.

The hc_players has been carried over from your previous work with the soccer line-up data.

Instructions

100 XP
  • Create a dendrogram object dend_players from your hclust result using the function as.dendrogram().
  • Plot the dendrogram.
  • Using the color_branches() function create & plot a new dendrogram with clusters colored by a cut height of 20.
  • Repeat the above step with a height of 40.