assignCluster

0th

Percentile

Append a Cluster Membership Variable to a Dataframe

Correctly creates a cluster membership variable that can be attached to a dataframe when only a subset of the observations in that dataframe were used to create the clustering solution. NAs are assigned to the observations of the original dataframe not used in creating the clustering solution.

Keywords
misc
Usage
assignCluster(clusterData, origData, clusterVec)
Arguments
clusterData
The data matrix used in the clustering solution. The data matrix may have have only a subset of the observations contained in the original dataframe.
origData
The original dataframe from which the data used in the clustering solution were taken.
clusterVec
An integer variable containing the cluster membership assignments for the observations used in creating the clustering solution. This vector can be created using cutree for clustering solutions generated by hclust or th
Value

  • A factor (with integer labels) that indicate the cluster assignment for each observation, with an NA value given to observations not used in the clustering solution.

See Also

hclust, cutree, kmeans, KMeans

Aliases
  • assignCluster
Examples
data(USArrests)
  USArrkm3 <- KMeans(USArrests[USArrests$UrbanPop<66, ], centers=3)
  assignCluster(USArrests[USArrests$UrbanPop<66, ], USArrests, USArrkm3$cluster)
Documentation reproduced from package Rcmdr, version 1.3-5, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.