Learn R Programming

coda.plot (version 0.1.9)

ternary_diagram: Ternary Diagram

Description

Generates a ternary diagram from compositional data, with options to center, scale, and color the points by group. Optionally overlays principal components.

Usage

ternary_diagram(
  X,
  group = NULL,
  center = FALSE,
  scale = FALSE,
  show_pc = FALSE
)

Value

A ggtern plot object (inherits from ggplot).

Arguments

X

A numeric matrix or data frame of compositional data with exactly three columns.

group

A factor or character vector indicating groups for color coding (optional).

center

Logical. Should the data be centered before plotting? Default is FALSE.

scale

Logical. Should the data be scaled to unit variance? Default is FALSE.

show_pc

Logical. If TRUE, principal components are overlaid. Default is FALSE.

Examples

Run this code
X = milk_cows[,5:7]
group = milk_cows$group
ternary_diagram(X, group = group)

Run the code above in your browser using DataLab