kclustering: K-means cluster analysis

View source: R/kclustering.R

kclusteringR Documentation

K-means cluster analysis

Description

K-means cluster analysis

Usage

kclustering(
  data,
  k = NULL,
  labels = NULL,
  nclumax = 10,
  nruns = 10,
  iter.max = 50,
  algorithm = "Hartigan-Wong"
)

Arguments

data

numeric data frame.

k

integer, number of clusters.

labels

character, row labels.

nclumax

integer, maximum number of clusters (when k=NULL) used for calculating the explained variance as function of the number of clusters.

nruns

integer, run the k-means algorithm nruns times and chooses the best solution according to a maximum explained variance criterion.

iter.max

integer, maximum number of iterations allowed in k-means clustering (see kmeans).

algorithm

character, the algorithm used in k-means clustering (see kmeans).

Details

The kclustering function performs a preliminary standardization of columns in data.

Value

A kclustering object.

If k is NULL, the kclustering object is a list of 3 elements:

  • k NULL

  • clusterRange integer vector, values of k (from 1 to nclumax) at which the variance between of the clusterization is evaluated

  • VarianceBetween numeric vector, values of the variance between evaluated for k in clusterRange

If k is not NULL, the kclustering object is a list of 4 elements:

  • k integer, number of clusters

  • Subjects data frame, subjects' cluster identifiers

  • ClusterList list, clusters' composition

  • Profiles data frame, clusters' profiles, i.e. the average of the variables within clusters and the cluster eterogeineity index (CHI)

Author(s)

Marco Sandri, Paola Zuccolotto, Marica Manisera (basketballanalyzer.help@unibs.it)

References

P. Zuccolotto and M. Manisera (2020) Basketball Data Science: With Applications in R. CRC Press.

See Also

plot.kclustering, kmeans

Examples

FF <- fourfactors(Tbox,Obox)
X <- with(FF, data.frame(OD.Rtg=ORtg/DRtg,
               F1.r=F1.Def/F1.Off, F2.r=F2.Off/F2.Def,
               F3.O=F3.Def, F3.D=F3.Off))
X$P3M <- Tbox$P3M
X$STL.r <- Tbox$STL/Obox$STL
kclu1 <- kclustering(X)
plot(kclu1)
kclu2 <- kclustering(X, k=9)
plot(kclu2)

sndmrc/BasketAnalyzeR documentation built on June 6, 2023, 12:52 a.m.