Hierarchical Clustering in R: The Essentials

Hierarchical Clustering in R: The Essentials

Hierarchical Clustering in R: The Essentials

The Hierarchical clustering [or hierarchical cluster analysis (HCA)] method is an alternative approach to partitional clustering for grouping objects based on their similarity.

In contrast to partitional clustering, the hierarchical clustering does not require to pre-specify the number of clusters to be produced.

Hierarchical clustering can be subdivided into two types:

  • Agglomerative clustering in which, each observation is initially considered as a cluster of its own (leaf). Then, the most similar clusters are successively merged until there is just one single big cluster (root).
  • Divise clustering, an inverse of agglomerative clustering, begins with the root, in witch all objects are included in one cluster. Then the most heterogeneous clusters are successively divided until all observation are in their own cluster.

The result of hierarchical clustering is a tree-based representation of the objects, which is also known as dendrogram (see the figure below).

The dendrogram is a multilevel hierarchy where clusters at one level are joined together to form the clusters at the next levels. This makes it possible to decide the level at which to cut the tree for generating suitable groups of a data objects.

In this course, you will learn:

  • The hierarchical clustering algorithms
  • Examples of computing and visualizing hierarchical clustering in R
  • How to cut dendrograms into groups.
  • How to compare two dendrograms.
  • Solutions for handling dendrograms of large data sets.

Related Book

Practical Guide to Cluster Analysis in R


  1. In this article, we start by describing the agglomerative clustering algorithms. Next, we provide R lab sections with many examples for computing and visualizing hierarchical clustering. We continue by explaining how to interpret dendrogram. Finally, we provide R codes for cutting dendrograms into groups.

Comments ( 5 )

  • LZarba

    Hi, I am new to this site and can’t find how to start the course. Where should I click to start the lesson? Thanks

    • Kassambara

      Hi, you just need to click on a specific lesson title to read the corresponding contents

      • LZarba


  • Monokill

    this is such a helpful course! Where can I download the raw data USarrests so I can follow along with the steps in R on my computer?

    • Kassambara

      USArrests is a built-in R data set. So, to load it, just type this in R console: data(“USArrests”)

Give a comment

Want to post an issue with R? If yes, please make sure you have read this: How to Include Reproducible R Script Examples in Datanovia Comments