clustcentroid: Cluster centers of a classification

View source: R/clustcentroid.R

clustcentroidR Documentation

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)

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.

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

Note

In order to assign new plot record data into a predefined set of classes, one should use functions as.vegclust and vegclass instead.

Author(s)

Miquel De Cáceres, CREAF

See Also

as.vegclust, vegclass, vegclust, kmeans

Examples

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


vegclust documentation built on Aug. 25, 2022, 9:08 a.m.