View source: R/clustcentroid.R
clustcentroid | R Documentation |
Function clustcentroid
calculates the centroid (multivariate average) coordinates of a classification. Function clustmedoid
determines the medoid (object whose average dissimilarity to all the other objects is minimal) for each cluster in the classification.
clustcentroid(x, y, m = 1)
clustmedoid(x, y, m = 1)
x |
Community data, a site-by-species data frame. In function |
y |
It can be (a) A vector indicating the cluster that each object in |
m |
Fuzziness exponent, only effective when |
Function clustcentroid
returns a group-by-species matrix containing species average abundance values (i.e. the coordinates of each cluster centroid). Function clustmedoid
returns a vector of indices (medoids).
In order to assign new plot record data into a predefined set of classes, one should use functions as.vegclust
and vegclass
instead.
Miquel De Cáceres, CREAF
as.vegclust
, vegclass
, vegclust
, kmeans
## Loads stats
library(stats)
## Loads data
data(wetland)
## This equals the chord transformation
## (see also \code{\link{decostand}} in package 'vegan')
wetland.chord = as.data.frame(sweep(as.matrix(wetland), 1,
sqrt(rowSums(as.matrix(wetland)^2)), "/"))
## Performs a K-means clustering
wetland.km = kmeans(wetland.chord, centers=3, nstart=10)
## Gets the coordinates corresponding to the centroids of KM clusters
clustcentroid(wetland.chord, y=wetland.km$cluster)
## Gets the object indices corresponding to the medoids of KM clusters
clustmedoid(wetland.chord, y=wetland.km$cluster)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.