Chapter 5: Clustering

Author: Amy Wagaman

Digital resources supplementing the chapter


Much of the R code shown in the chapter is available for viewing and downloading from this repository, as well as the necessary related data files.

Small clustering example

View R Markdown file

View generated PDF

Iris data visualization

View R Markdown file

View generated PDF

Wine data, k-means clustering

View R Markdown file

To run that R Markdown file on your own machine, you would need the associated data file in the same folder as the .Rmd file. You can get the data file here.

View generated PDF

Wine data, hierarchical clustering

View R Markdown file

To run that R Markdown file on your own machine, you would need the associated data file in the same folder as the .Rmd file. You can get the data file here.

View generated PDF

Wine data, model-based clustering

View R Markdown file

To run that R Markdown file on your own machine, you would need the associated data file in the same folder as the .Rmd file. You can get the data file here. You will also need a file containing BIC values, which you should also place in the same folder as the .Rmd file. You can get that second file here.

View generated PDF

Wine data, density-based clustering

View R Markdown file

To run that R Markdown file on your own machine, you would need the associated data file in the same folder as the .Rmd file. You can get the data file here.

View generated PDF

Clustering on dolphin network data

View R Markdown file

View generated PDF

To run that R Markdown file on your own machine, you would need the associated data file in the same folder as the .Rmd file. You can get the data file here.

k-means clustering with bad initial centroids

View R Markdown file

View generated PDF

College Scorecard, two types of clustering compared

View R Markdown file

To run that R Markdown file on your own machine, you would need the associated data file in the same folder as the .Rmd file. You can get the data file here.

View generated PDF