Skip to contents

Computes linear discriminant analysis (LDA) on classified cluster groups, and determines the goodness of classification for each cluster group. See MASS::lda() for details.


cluster_discrimination(x, cluster_groups = NULL, ...)



A data frame


Group classification of the cluster analysis, which can be retrieved from the cluster_analysis() function.


Other arguments to be passed to or from.

See also

n_clusters() to determine the number of clusters to extract, cluster_analysis() to compute a cluster analysis and check_clusterstructure() to check suitability of data for clustering.


if (requireNamespace("MASS", quietly = TRUE)) {
  # Retrieve group classification from hierarchical cluster analysis
  clustering <- cluster_analysis(iris[, 1:4], n = 3)

  # Goodness of group classification
#> # Accuracy of Cluster Group Classification via Linear Discriminant Analysis (LDA)
#>  Group Accuracy
#>      1   82.98%
#>      2   94.34%
#>      3  100.00%
#> Overall accuracy of classification: 92.67%