medoids {cluster}  R Documentation 
pam
consistent Medoids from ClusteringGiven a data matrix or dissimilarity x
for say n
observational units and a clustering,
compute the pam()
consistent medoids.
medoids(x, clustering, diss = inherits(x, "dist"), USE.NAMES = FALSE, ...)
x 
Either a data matrix or data frame, or dissimilarity matrix or
object, see also 
clustering 
an integer vector of length 
diss 
see also 
USE.NAMES 
a logical, typical false, passed to the

... 
optional further argument passed to 
a numeric vector of length
Martin Maechler, after being asked how pam()
could be used
instead of kmeans()
, starting from a previous clustering.
pam
, kmeans
.
Further, cutree()
and agnes
(or hclust
).
## 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={})
}