cluster_elements {AnimalSequences} | R Documentation |
Cluster Elements Using Hierarchical Clustering
Description
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.
Usage
cluster_elements(distance_matrix, method = "complete", plot = TRUE)
Arguments
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. |
Details
Hierarchical clustering is performed using the specified method. If plot
is TRUE, the function will generate a dendrogram to visualize the clustering.
Value
An object of class "hclust"
representing the hierarchical clustering result.
Examples
# 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)
[Package AnimalSequences version 0.2.0 Index]