plot_sqi: Plot Soil Quality Index Across Groups

View source: R/visualization.R

plot_sqiR Documentation

Plot Soil Quality Index Across Groups

Description

Creates a grouped bar chart of SQI values per group, with optional error bars (standard deviation computed across replicate observations before indexing) and significance letters.

Usage

plot_sqi(
  sqi_result,
  sqi_col,
  group_col,
  fill_col = NULL,
  letters_df = NULL,
  title = "Soil Quality Index",
  y_label = "SQI (0-1)",
  palette = c("#2d6a4f", "#52b788", "#95d5b2", "#d8f3dc", "#b7e4c7")
)

Arguments

sqi_result

A data frame returned by any sqi_*() function.

sqi_col

Character. Name of the SQI column to plot.

group_col

Character. Grouping column for the x-axis.

fill_col

Character or NULL. Column for fill (e.g., "Depth" to produce side-by-side bars).

letters_df

Data frame with columns Group and Letter (from sqi_anova), or NULL.

title

Character. Plot title.

y_label

Character. Y-axis label.

palette

Character vector of colours.

Value

A ggplot object.

Examples

data(soil_data)
cfg <- make_config(
  variable = c("pH","EC","BD","OC","MBC","Clay"),
  type     = c("opt","less","less","more","more","opt"),
  opt_low  = c(6.0, NA, NA, NA, NA, 20),
  opt_high = c(7.0, NA, NA, NA, NA, 35)
)
scored <- score_all(soil_data, cfg, group_cols = c("LandUse","Depth"))
res    <- sqi_linear(scored, cfg, group_cols = c("LandUse","Depth"))
plot_sqi(res, sqi_col = "SQI_linear", group_col = "LandUse",
         fill_col = "Depth")


SQIpro documentation built on April 20, 2026, 5:06 p.m.