clusterCenters: Cluster Center function

Description Usage Arguments Value Author(s) Examples

Description

Given a matrix of data with its cluster assignments, return a matrix of the cluster centers. Note that several euclidean-based methods will return cluster centers.

Usage

1

Arguments

x

a data frame whose first column consists of cluster assignments. Note these cluster assignments must be in the form of integers.

Value

centers

A matrix whose rows correspond to the vector mean (the cluster center) of all the elements in a particular cluster. For example, centers[1,] contains the vector mean for all the elements with cluster assignment 1.

Note that if there are no elements in a cluster (as in the case of SOM with an unused map), that row will have NAs.

Author(s)

Ted Laderas (laderast@ohsu.edu)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  ## = don't run
  ##clusterassign is a vector of cluster assignments
  ##such as the output from kmeans
  ##data is matrix of actual data

  #example of use using k-means
  x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
           matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
  cl <- kmeans(x, 2, 20)
  clusterassign <- cl$cluster

  clustmatrix <- cbind(clusterassign, x)
  centers <- clusterCenters(as.data.frame(clustmatrix))
  

laderast/Consense documentation built on May 20, 2019, 7:32 p.m.