## save the distance matrix dist.prices <- dist(prices) ### simple linkage model.singleLinkage <- hclust(dist.prices, method = "single") plot(model.singleLinkage) cutree(model.singleLinkage, k = 3) plot(model.singleLinkage) rect.hclust(model.singleLinkage, k = 3, border = "red") ### complete linkage model.completeLinkage <- hclust(dist.prices, method = "complete") plot(model.completeLinkage) rect.hclust(model.completeLinkage, k=3, border="red") ### average linkage model.averageLinkage <- hclust(dist.prices, method = "average") plot(model.averageLinkage) rect.hclust(model.averageLinkage, k=3, border="red") ### Ward's model model.Ward <- hclust(dist.prices, method = "ward.D") plot(model.Ward) rect.hclust(model.Ward, k=3, border="red")