Medoid is the point that has minimum distance to all other points in the cluster.

medoid(members, dist_mat)

Arguments

members

index vector indicating which observation belongs to the cluster.

dist_mat

distance matrix of the whole data set. A class of dist object must be coerced to a matrix before using.

Value

index of the medoid point in the members vector.

Examples

# \donttest{ library(cluster) data(ruspini) ruspini4sol <- MonoClust(ruspini, nclusters = 4) ruspini4sol
#> n = 75 #> #> Node) Split, N, Cluster Inertia, Proportion Inertia Explained, #> * denotes terminal node #> #> 1) root 75 244373.900 0.6344215 #> 2) y < 91 35 43328.460 0.9472896 #> 4) x < 37 20 3689.500 * #> 5) x >= 37 15 1456.533 * #> 3) y >= 91 40 46009.380 0.7910436 #> 6) x < 63.5 23 3176.783 * #> 7) x >= 63.5 17 4558.235 * #> #> Note: One or more of the splits chosen had an alternative split that reduced inertia by the same amount. See "alt" column of "frame" object for details.
medoid(which(ruspini4sol$membership == 4), ruspini4sol$dist)
#> [1] 10
# Check with the output with "4" label ruspini4sol$medoids
#> 4 5 6 7 #> 10 70 32 52
# }