To perform hierarchical cluster analysis, follow these steps:
- Read the data and normalize it to the same scale. We will ignore the Country variable during scaling (as it is a categorical variable):
> proteinIntake <- read.csv("protein.csv") > head(proteinIntake)
Here is how it will look:
> proteinIntakeScaled = as.data.frame(scale(proteinIntake[,-1]))> proteinIntakeScaled$Country =proteinIntake$Country
- Now use agglomerative hierarchical clustering to cluster the scaled protein intake data:
> hc = hclust(dist(proteinIntakeScaled, method="euclidean"), method="ward.D2")> hcCall:hclust(d = dist(proteinIntakeScaled, method ...