## From example(agnes):
data(votes.repub)
agn1 <- agnes(votes.repub, metric = "manhattan", stand = TRUE)
agn2 <- agnes(daisy(votes.repub), diss = TRUE, method = "complete")
agnS <- agnes(votes.repub, method = "flexible", par.meth = 0.625)
for(k in 2:11) {
print(table(cl.k <- cutree(agnS, k=k)))
stopifnot(length(cl.k) == nrow(votes.repub), 1 <= cl.k, cl.k <= k, table(cl.k) >= 2)
m.k <- medoids(votes.repub, cl.k)
cat("k =", k,"; sort(medoids) = "); dput(sort(m.k), control={})
}
Run the code above in your browser using DataLab