silinfo_widths: silinfo_widths

View source: R/silinfo.R

silinfo_widthsR Documentation

silinfo_widths

Description

Per-sample silhouette widths

Usage

silinfo_widths(x, k)

Arguments

x

a silinfo object, as returned by nk()

k

a single value among the candidate k used in nk()

Details

Extract the fine-grained silhouette information of one k from an nk() result: one row per sample, with the cluster the sample was assigned to, its neighbour cluster and its silhouette width.

Value

a data.frame with one row per sample and the columns sample, cluster, neighbor and sil_width. The rows keep the order in which the clusterer returned them – for cluster::pam() that is by cluster and, within a cluster, by decreasing sil_width – so the rows should be aligned by sample rather than by position. The per-cluster average silhouette widths are attached as the "clus.avg.widths" attribute, and are also available as x$silinfo[[i]]$clus.avg.widths, where i is the position of k in x$k.

Author(s)

Guangchuang Yu

See Also

nk(), autoplot()

Examples

x <- nk(iris[,-5], 2:4)
head(silinfo_widths(x, 3))
attr(silinfo_widths(x, 3), "clus.avg.widths")

tidydr documentation built on Oct. 9, 2026, 5:07 p.m.