Learn R Programming

sjPlot (version 2.0.0)

sjc.kgap: Compute gap statistics for k-means-cluster

Description

An implementation of the gap statistic algorithm from Tibshirani, Walther, and Hastie's "Estimating the number of clusters in a data set via the gap statistic". This function calls the clusGap-function of the cluster-package to calculate the data for the plot.

Usage

sjc.kgap(x, max = 10, B = 100, SE.factor = 1, method = "Tibs2001SEmax",
  plotResults = TRUE)

Arguments

Value

An object containing the used data frame for plotting, the ggplot object and the number of found cluster.

References

  • Tibshirani R, Walther G, Hastie T (2001) Estimating the number of clusters in a data set via gap statistic. J. R. Statist. Soc. B, 63, Part 2, pp. 411-423
  • Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2013). cluster: Cluster Analysis Basics and Extensions. R package version 1.14.4. (http://cran.r-project.org/package=cluster{web})

See Also

sjc.elbow

Examples

Run this code
# plot gap statistic and determine best number of clusters
# in mtcars dataset
sjc.kgap(mtcars)

# and in iris dataset
sjc.kgap(iris[,1:4])

Run the code above in your browser using DataLab