Aan de slagGa gratis aan de slag

Hierarchical clustering: Occupation trees

In the previous exercise you have learned that the oes data is ready for hierarchical clustering without any preprocessing steps necessary. In this exercise you will take the necessary steps to build a dendrogram of occupations based on their yearly average salaries and propose clusters using a height of 100,000.

Deze oefening maakt deel uit van de cursus

Cluster Analysis in R

Cursus bekijken

Oefeninstructies

  • Calculate the Euclidean distance between the occupations and store this in dist_oes.
  • Run hierarchical clustering using average linkage and store in hc_oes.
  • Create a dendrogram object dend_oes 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 100,000.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Calculate Euclidean distance between the occupations
dist_oes <- dist(___, method = ___)

# Generate an average linkage analysis 
hc_oes <- hclust(___, method = ___)

# Create a dendrogram object from the hclust variable
dend_oes <- as.dendrogram(___)

# Plot the dendrogram
plot(___)

# Color branches by cluster formed from the cut at a height of 100000
dend_colored <- color_branches(___, h = ___)

# Plot the colored dendrogram
plot(___)
Code bewerken en uitvoeren