Skip to contents

Determines the medoid of one or several subsets of elements using a distance matrix.

Usage

medoid(distances, byName = FALSE)

medoids_partition(distances, partition, clusters = NULL)

Arguments

distances

The distance matrix used to find the medoid(s) (distance matrix).

byName

TRUE if the returned result should be the row name corresponding to the medoid, FALSE if it should be the row number. Ignored if distances is not named. (flag)

partition

The partition for which the medoids of each cluster should be determined (vector).

clusters

The set of clusters for which the medoid should be calculated (all by default).

Value

For medoid: depending on byName, the name or the identifier of the medoid.

For medoids_partition: a named numeric vector indicating, for each cluster or a subset of them, the identifier of its medoid.

Functions

  • medoid(): Determine the medoid of a set.

  • medoids_partition(): Calculation of the medoid for each cluster in a partition.

Examples

M <- matrix(c(0.0, 1.0, 2.0,
              1.0, 0.0, 3.0,
              2.0, 3.0, 00.))

medoid(M)
#> [1] 1