data("USArrests")
df <- na.omit(USArrests)
df <- scale(df)
head(df)
## Murder Assault UrbanPop Rape
## Alabama 1.24256408 0.7828393 -0.5209066 -0.003416473
## Alaska 0.50786248 1.1068225 -1.2117642 2.484202941
## Arizona 0.07163341 1.4788032 0.9989801 1.042878388
## Arkansas 0.23234938 0.2308680 -1.0735927 -0.184916602
## California 0.27826823 1.2628144 1.7589234 2.067820292
## Colorado 0.02571456 0.3988593 0.8608085 1.864967207
d <- dist(df, method = "euclidean")
hc <- hclust(d, method = "ward.D")
plot(hc, cex = 0.6, hang = -1)

hc_d2 <- hclust(d, method = "ward.D2")
plot(hc_d2, cex = 0.6, hang = -1)

hc_single <- hclust(d, method = "single")
plot(hc_single, cex = 0.6, hang = -1)

hc_complete <- hclust(d, method = "complete")
plot(hc_complete, cex = 0.6, hang = -1)

hc_av <- hclust(d, method = "average")
plot(hc_av, cex = 0.6, hang = -1)

hc_mcq <- hclust(d, method = "mcquitty")
plot(hc_mcq, cex = 0.6, hang = -1)

hc_median <- hclust(d, method = "median")
plot(hc_median, cex = 0.6, hang = -1)

hc_centroid <- hclust(d, method = "centroid")
plot(hc_centroid, cex = 0.6, hang = -1)
