LDA_Chart: Linear Discriminant Analysis Chart

View source: R/LDA_Chart.R

LDA_ChartR Documentation

Linear Discriminant Analysis Chart

Description

Performs a linear discriminant analysis (LDA) to project data into maximum-separation dimensions. Includes a comprehensive discrimination summary detailing variance explained, a leave-one-out cross-validation confusion matrix, and misclassification rates to rigorously assess source separability.

Usage

LDA_Chart(
  data,
  Plot3D = FALSE,
  text = FALSE,
  colors = NULL,
  interactive = FALSE,
  seed = NULL,
  verbose = TRUE
)

LDA_plot(
  data,
  Plot3D = FALSE,
  text = FALSE,
  colors = NULL,
  interactive = FALSE,
  seed = NULL,
  verbose = TRUE
)

LDAPlot(
  data,
  Plot3D = FALSE,
  text = FALSE,
  colors = NULL,
  interactive = FALSE,
  seed = NULL,
  verbose = TRUE
)

Arguments

data

Data frame. Contains source and mixture data in standard format.

Plot3D

Logical. If TRUE, renders a 3D scatter plot instead of a 2D projection. Default is FALSE.

text

Logical. If TRUE, overlays the sample identification numbers on the plot. Default is FALSE.

colors

Character vector. Custom colors for the source groups. Default is NULL.

interactive

Logical. If TRUE, renders an interactive HTML widget for 3D plots. Default is FALSE.

seed

Integer. Random seed for reproducibility. Default is NULL.

verbose

Logical. Whether to print discrimination summaries and variance explained to the console. Default is TRUE.

Value

Invisibly returns a named list containing:

lda

An object of class lda representing the fitted linear discriminant model.

confusion

A cross-tabulation table of leave-one-out cross-validation predictions versus actual sources.

prop_var

A numeric vector indicating the percentage of variance explained by each discriminant axis.

Examples

data <- data.frame(
   ID = paste0("S", 1:12),
   Group = rep(c("SourceA", "SourceB", "SourceC", "Mixture"), each = 3),
   Tracer1 = c(10, 12, 11, 20, 22, 21, 30, 31, 32, 20, 21, 22),
   Tracer2 = c(5, 6, 5, 15, 14, 16, 25, 26, 24, 15, 15, 16),
   Tracer3 = c(1, 2, 1.5, 5, 6, 5.5, 9, 10, 9.5, 5, 5.5, 6)
)
LDA_Chart(data, seed = 123)


OceanTracer documentation built on Oct. 15, 2026, 5:09 p.m.