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

Exercise

Exploring the branches cut from the tree

The cutree() function you used in exercises 5 & 6 can also be used to cut a tree at a given height by using the h parameter. Take a moment to explore the clusters you have generated from the previous exercises based on the heights 20 & 40.

Instructions

100 XP
  • Build the cluster assignment vector clusters_h20 using cutree() with a h = 20.
  • Append the cluster assignments as a column cluster to the lineup data frame and save the results to a new data frame called lineup_h20_complete.
  • Repeat the above two steps for a height of 40, generating the variables clusters_h40 and lineup_h40_complete.
  • Use ggplot2 to create a scatter plot, colored by the cluster assignment for both heights.