View source: R/cluster_elements.R
cluster_elements | R Documentation |
This function performs hierarchical clustering on a distance matrix and optionally plots the dendrogram. It uses the specified method for clustering and can visualize the results.
cluster_elements(distance_matrix, method = "complete", plot = TRUE)
distance_matrix |
A matrix of distances between elements. Should be a symmetric matrix with row and column names representing elements. |
method |
A character string specifying the method for hierarchical clustering. Options include "complete", "average", "single", etc. Default is "complete". |
plot |
A logical value indicating whether to plot the dendrogram. Default is TRUE. |
Hierarchical clustering is performed using the specified method. If plot
is TRUE, the function will generate a dendrogram to visualize the clustering.
An object of class "hclust"
representing the hierarchical clustering result.
# Create a distance matrix
distance_matrix <- dist(matrix(rnorm(20), nrow = 5))
# Perform hierarchical clustering and plot the dendrogram
cluster_elements(distance_matrix, method = "complete", plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.