Cluster centers of a classification
clustcentroid.Rd
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.
Arguments
- x
Community data, a site-by-species data frame. In function
clustmedoid
,x
can alternatively be an object of classdist
(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 classvegclust
orvegclass
- 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.
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)
#> Abefic Merhed Alyvag Pancam Abemos Melcor Ludoct
#> 1 0.00000000 0.00000000 0.04696958 0.07606533 0.01558699 0.15317754 0.00000000
#> 2 0.00000000 0.00000000 0.00000000 0.02725749 0.00000000 0.06157316 0.00000000
#> 3 0.01825742 0.06770211 0.00000000 0.35635911 0.01458650 0.27504998 0.01889822
#> Eupvac Echpas Passcr Poa2 Carhal Dendio Casobt
#> 1 0.05023873 0.06646064 0.00000000 0.01041893 0.06911470 0.00000000 0.00000000
#> 2 0.03879374 0.04762643 0.00000000 0.00000000 0.03679444 0.01572125 0.01631471
#> 3 0.20498936 0.10174214 0.02581989 0.00000000 0.00000000 0.00000000 0.00000000
#> Aesind Cyprot Ipocop Cynarc Walind Sessp. Phynod
#> 1 0.07475403 0.08126971 0.01262691 0.01262691 0.06377158 0.1041481 0.71534308
#> 2 0.00000000 0.00000000 0.00000000 0.00000000 0.06827998 0.1437923 0.00000000
#> 3 0.01889822 0.17597447 0.03974967 0.43238581 0.07754611 0.1569788 0.06361634
#> Echell Helind Ipoaqu Orysp. Elesp. Psespi Ludads
#> 1 0.1191200 0.17218890 0.04775048 0.1720463 0.1377765 0.02691262 0.000000
#> 2 0.0491431 0.12531919 0.05532759 0.6491987 0.1535492 0.19245622 0.204177
#> 3 0.1120500 0.01889822 0.03657589 0.0400000 0.0000000 0.00000000 0.000000
#> Polatt Poa1 Helcri Physp. Goopur
#> 1 0.00000000 0.01282895 0.01282895 0.00000000 0.00000000
#> 2 0.09678166 0.00000000 0.00000000 0.01153624 0.01153624
#> 3 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## Gets the object indices corresponding to the medoids of KM clusters
clustmedoid(wetland.chord, y=wetland.km$cluster)
#> 12 2 24
#> 23 11 34