Learn R Programming

msos (version 1.2.0)

silhouette.km: Silhouettes for \(K\)-Means Clustering

Description

Find the silhouettes (12.9) for K-means clustering from the data and and the groups' centers.

Usage

silhouette.km(x, centers)

Arguments

x

The \(N \times P\) data matrix.

centers

The \(K \times P\) matrix of centers (means) for the \(K\) Clusters, row \(k\) being the center for cluster \(K\).

Value

The \(n\)-vector of silhouettes, indexed by the observations' indices.

Details

This function is a bit different from the silhouette function in the cluster package, Maechler et al., 2005.

Examples

Run this code
# NOT RUN {
# Uses sports data.
data(sportsranks)

# Obtain the K-means clustering for sports ranks.
kms <- kmeans(sportsranks, centers = 5, nstart = 10)

# Silhouettes
sil <- silhouette.km(sportsranks, kms$centers)
# }

Run the code above in your browser using DataLab