The hclust()
function implements hierarchical clustering in R. In the following
example we use the data from K-means Clustering 11 to plot the hierarchical
clustering dendrogram using complete, single, and average linkage clustering,
with Euclidean distance as the dissimilarity measure. We begin by
clustering observations using complete linkage. The dist()
function is used
to compute the 50 × 50 inter-observation Euclidean distance matrix.
hc.complete <- hclust(dist(x), method = "complete")
We could just as easily perform hierarchical clustering with average or
single linkage instead by setting the method argument to average
or single
.
Try performing hierarchical clustering with average and single linkage.
Store the results in hc.average
and hc.single
respectively.