Learn R Programming

sharp (version 1.4.7)

KMeansClustering: (Sparse) K-means clustering

Description

Runs k-means clustering using implementation from kmeans. This function is not using stability.

Usage

KMeansClustering(xdata, nc = NULL, Lambda = NULL, ...)

Value

A list with:

comembership

an array of binary and symmetric co-membership matrices.

weights

a matrix of median weights by feature.

Arguments

xdata

data matrix with observations as rows and variables as columns.

nc

matrix of parameters controlling the number of clusters in the underlying algorithm specified in implementation. If nc is not provided, it is set to seq(1, tau*nrow(xdata)).

Lambda

vector of penalty parameters (see argument wbounds in KMeansSparseCluster).

...

additional parameters passed to kmeans (if Lambda is NULL) or KMeansSparseCluster.

References

SparseClusteringsharp

See Also

Other clustering algorithms: DBSCANClustering(), GMMClustering(), HierarchicalClustering(), PAMClustering()

Examples

Run this code

# Data simulation
set.seed(1)
simul <- SimulateClustering(n = c(10, 10), pk = 50)

# K means clustering
mykmeans <- KMeansClustering(xdata = simul$data, nc = seq_len(20))

# Sparse K means clustering
if (requireNamespace("sparcl", quietly = TRUE)) {
  mykmeans <- KMeansClustering(
    xdata = simul$data, nc = seq_len(20),
    Lambda = c(2, 5)
  )
}

Run the code above in your browser using DataLab