Learn R Programming

sjPlot (version 2.0.0)

sjc.cluster: Compute hierarchical or kmeans cluster analysis

Description

Compute hierarchical or kmeans cluster analysis and return the group association for each observation as vector.

Usage

sjc.cluster(data, groupcount = NULL, method = c("hclust", "kmeans"),
  distance = c("euclidean", "maximum", "manhattan", "canberra", "binary",
  "minkowski"), agglomeration = c("ward", "ward.D", "ward.D2", "single",
  "complete", "average", "mcquitty", "median", "centroid"), iter.max = 20,
  algorithm = c("Hartigan-Wong", "Lloyd", "MacQueen"))

Arguments

Value

The group classification for each observation as vector. This group classification can be used for sjc.grpdisc-function to check the goodness of classification. The returned vector includes missing values, so it can be appended to the original data frame data.

References

Maechler M, Rousseeuw P, Struyf A, Hubert M, Hornik K (2014) cluster: Cluster Analysis Basics and Extensions. R package.

Examples

Run this code
# Hierarchical clustering of mtcars-dataset
groups <- sjc.cluster(mtcars, 5)

# K-means clustering of mtcars-dataset
groups <- sjc.cluster(mtcars, 5, method="k")

Run the code above in your browser using DataLab