make_config: Build a Variable Configuration Table

View source: R/validate.R

make_configR Documentation

Build a Variable Configuration Table

Description

Constructs a variable configuration data frame that specifies the scoring function type and relevant parameters for each soil indicator. This configuration table is the central object passed to all scoring and indexing functions in SQIpro.

Usage

make_config(
  variable,
  type,
  opt_low = rep(NA_real_, length(variable)),
  opt_high = rep(NA_real_, length(variable)),
  min_val = rep(NA_real_, length(variable)),
  max_val = rep(NA_real_, length(variable)),
  weight = rep(1, length(variable)),
  description = rep(NA_character_, length(variable))
)

Arguments

variable

Character vector of variable names (must match column names in the data).

type

Character vector of scoring types, one per variable. Must be one of:

"more"

Higher values are better (e.g., organic carbon, CEC, microbial biomass).

"less"

Lower values are better (e.g., bulk density, EC, heavy metals).

"opt"

A specific optimum value or range is best (e.g., pH, clay content). Requires opt_low and opt_high.

"trap"

A trapezoidal function with a flat optimum plateau and tapered shoulders. Requires all four boundary parameters.

"custom"

User-supplied scoring function via score_custom.

opt_low

Numeric vector. Lower bound of optimum range (required for "opt" and "trap" types; NA otherwise).

opt_high

Numeric vector. Upper bound of optimum range (required for "opt" and "trap" types; NA otherwise).

min_val

Numeric vector. Absolute minimum value (required for "trap"; NA otherwise). Values at or below this receive a score of 0.

max_val

Numeric vector. Absolute maximum value (required for "trap"; NA otherwise). Values at or above this receive a score of 0.

weight

Numeric vector of user-defined weights (0–1). Used only when method = "weighted" in sqi_linear. Defaults to 1 (equal weights).

description

Character vector. Optional human-readable description of each variable (units, rationale). Useful for automated reports.

Value

A data frame (class sqi_config) with one row per variable.

References

Doran, J.W., & Parkin, T.B. (1994). Defining and assessing soil quality. In J.W. Doran et al. (Eds.), Defining Soil Quality for a Sustainable Environment, pp. 1–21. SSSA Special Publication 35. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2136/sssaspecpub35.c1")}

Andrews, S.S., Karlen, D.L., & Cambardella, C.A. (2004). The soil management assessment framework. Soil Science Society of America Journal, 68(6), 1945–1962. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2136/sssaj2004.1945")}

Examples

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),
  description = c("Soil pH (H2O)",
                  "Electrical Conductivity (dS/m)",
                  "Bulk Density (g/cm3)",
                  "Organic Carbon (%)",
                  "Microbial Biomass Carbon (mg/kg)",
                  "Clay content (%)")
)
print(cfg)


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