cluster_centers: Find the cluster centers in your data

View source: R/cluster_centers.R

cluster_centersR Documentation

Find the cluster centers in your data

Description

For each cluster, computes the mean (or other indices) of the variables. Can be used to retrieve the centers of clusters. Also returns the within Sum of Squares.

Usage

cluster_centers(data, clusters, fun = mean, ...)

Arguments

data

A data.frame.

clusters

A vector with clusters assignments (must be same length as rows in data).

fun

What function to use, mean by default.

...

Other arguments to be passed to or from other functions.

Value

A dataframe containing the cluster centers. Attributes include performance statistics and distance between each observation and its respective cluster centre.

Examples

k <- kmeans(iris[1:4], 3)
cluster_centers(iris[1:4], clusters = k$cluster)
cluster_centers(iris[1:4], clusters = k$cluster, fun = median)

parameters documentation built on Nov. 22, 2022, 1:05 a.m.