run_clustering {clusterWebApp} | R Documentation |
Perform clustering analysis
Description
This function performs clustering on a numeric matrix using one of six common clustering methods: KMeans, Hierarchical, DBSCAN, PAM, Gaussian Mixture Model (GMM), or Spectral Clustering.
Usage
run_clustering(data, method, k = 3, eps = 0.5, minPts = 5)
Arguments
data |
A numeric matrix or data frame, typically standardized, to be clustered. |
method |
A string indicating the clustering method to use. Options are: "KMeans", "Hierarchical", "DBSCAN", "PAM", "GMM", "Spectral". |
k |
An integer specifying the number of clusters. Required for KMeans, Hierarchical, PAM, GMM, and Spectral. |
eps |
A numeric value specifying the epsilon parameter for DBSCAN. Default is 0.5. |
minPts |
An integer specifying the minimum number of points for DBSCAN. Default is 5. |
Value
A list containing two elements:
- cluster
A vector of cluster labels assigned to each observation.
- silhouette
An object of class
silhouette
representing silhouette widths.
Examples
data(iris)
result <- run_clustering(scale(iris[, 1:4]), method = "KMeans", k = 3)
print(result$cluster)
if (interactive()) {
plot(result$silhouette)
}