Learn R Programming

vegclust (version 2.0.2)

clustcentroid: Cluster centers of a classification

Description

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.

Usage

clustcentroid(x, y, m = 1)
clustmedoid(x, y, m = 1)

Value

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).

Arguments

x

Community data, a site-by-species data frame. In function clustmedoid, x can alternatively be an object of class dist (otherwise, the dissimilarity measure is assumed to be the Euclidean distance).

y

It can be (a) A vector indicating the cluster that each object in x belongs to; (b) a fuzzy/hard site-by-group matrix of membership values; (c) an object of class vegclust or vegclass

m

Fuzziness exponent, only effective when y is a fuzzy membership matrix.

Author

Miquel De Cáceres, CREAF

See Also

as.vegclust, vegclass, vegclust, kmeans

Examples

Run this code
## 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)

Run the code above in your browser using DataLab