clustcentroid: Cluster centers of a classification

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/clustcentroid.R

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

1
2
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, Forest Science Center of Catalonia

See Also

as.vegclust, vegclass, vegclust, kmeans

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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 May 29, 2018, 9:04 a.m.