kmeansPlus: 'kmeansPlus'

Description Usage Arguments Examples

View source: R/kmeansPlus.R

Description

A tool to aid in the implementation of conventional k means clustering, kmeansPlus() provides the normal functionality of stats::kmeans() with some modest additions. In short, it allows the user to quickly plot results from kmeans(), as well as add cluster identifiers to the input dataframe as a new variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
kmeansPlus(
  data,
  k,
  exclude = NULL,
  full.output = TRUE,
  plot = TRUE,
  x = NULL,
  y = NULL,
  iter.max = 10,
  nstart = 1,
  algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"),
  trace = FALSE
)

Arguments

data

A matrix or dataframe containing numeric data in tidy format. This is equivalent to the 'x' argument from kmeans().

k

Either the desired number of clusters, or a set of initial (distinct) cluster centers. This is equivalent to the 'centers' argument from kmeans().

exclude

A vector, either numeric or character, indicating either indices or colnames of variables in 'data' that the user wishes to exclude. The excluded variable will not be removed from the tibble printed in the final output (when full.output and plot are set to FALSE), but it will be excluded from all clustering and vizualisation procedures.

full.output

A logical vector indicating whether the output of kmeansPlus() should include the full output of kmeans().

plot

A logical vector indicating whether the output of kmeansPlus() should include a plot.

x

A string (character vector of length 1) containing the colname of a variable from 'data' to be plotted on the x axis (if plot = TRUE).

y

A string (character vector of length 1) containing the colname of a variable from 'data' to be plotted on the y axis (if plot = TRUE).

iter.max

This is equivalent to the 'iter.max' argument from kmeans(), and is set to the same default.

nstart

This is equivalent to the 'nstart' argument from kmeans(), and is set to the same default.

algorithm

This is equivalent to the 'algorithm' argument from kmeans(), and is set to the same default.

trace

This is equivalent to the 'trace' argument from kmeans(), and is set to the same default.

Examples

1
2
kmeansPlus(data = iris, k = 3, exclude = "Species", full.output = TRUE, plot = TRUE,
x = "Sepal.Length", y = "Sepal.Width")

samrabi1/ada.classification documentation built on May 23, 2020, 7:01 a.m.