View source: R/compute_centroids.R
compute_centroids | R Documentation |
The compute_centroids function calculates the center and centroid of each cluster given a feature matrix, grid, and cluster assignments.
compute_centroids(feature_mat, grid, assignment, medoid = FALSE)
feature_mat |
A matrix of features, where columns represent data points and rows represent features. |
grid |
A matrix representing the spatial grid of data points. |
assignment |
A vector containing the cluster assignment for each data point. |
medoid |
A logical value indicating whether to calculate medoids instead of means for cluster centers and centroids. Default is FALSE. |
A list containing two elements:
center |
A matrix containing the centers of each cluster. |
centroid |
A matrix containing the centroids of each cluster. |
## Not run:
# Assuming `feature_mat`, `grid`, and `assignment` are available
centroids <- compute_centroids(feature_mat, grid, assignment)
# To compute medoids instead of means
medoids <- compute_centroids(feature_mat, grid, assignment, medoid=TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.