optimal_k: Using the elbow method to find the optimal number of clusters...

View source: R/optimal_k.R

optimal_kR Documentation

Using the elbow method to find the optimal number of clusters in K-means clustering

Description

This function is designed to find the optimal number of clusters in K-means clustering using the elbow method.

Usage

optimal_k(data, max.k, title = "Elbow Method for Finding the Optimal k")

Arguments

data

A numeric data.frame scaled with scale.

max.k

The max number of clusters to consider.

title

A character string of the elbow plot title.

Value

A ggplot.

Author(s)

Jianhai Zhang jzhan067@ucr.edu
Dr. Thomas Girke thomas.girke@ucr.edu

References

H. Wickham. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2016.

Examples

data <- iris[, 1:4]
dat.scl <- scale(data)
optimal_k(dat.scl, 5)

jianhaizhang/spatialHeatmap documentation built on July 31, 2024, 2:59 a.m.