Find the medoid sample of each cluster in a given distance matrix
getMedoidId(dist, cluster, N = 1L, na.rm = TRUE)
Arguments
- dist
A dist object
- cluster
The group information for the elements in the dist.
- N
The number of medoid sample to be returned.
- na.rm
A logical evaluating to TRUE or FALSE indicating whether NA
values should be stripped before the computation proceeds.
Value
The medoid element labels for each cluster.
Examples
x <- matrix(rnorm(100), nrow = 5)
dist <- dist(x)
group <- c('A', 'A', 'B', 'B', 'B')
getMedoidId(dist, group)
#> $A
#> [1] "1"
#>
#> $B
#> [1] "4"
#>