Data understanding and preparation
Let's start with loading the R packages that we will need for this chapter. As always, make sure that you have installed them first:
> library(cluster) #conduct cluster analysis > library(compareGroups) #build descriptive statistic tables > library(HDclassif) #contains the dataset > library(NbClust) #cluster validity measures > library(sparcl) #colored dendrogram
The dataset is in the HDclassif
package, which we installed. So, we can load the data and examine the structure with the str()
function:
> data(wine) > str(wine) 'data.frame':178 obs. of 14 variables: $ class: int 1 1 1 1 1 1 1 1 1 1 ... $ V1 : num 14.2 13.2 13.2 14.4 13.2 ... $ V2 : num 1.71 1.78 2.36 1.95 2.59 1.76 1.87 2.15 1.64 1.35 ... $ V3 ...
Get R: Unleash Machine Learning Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.