score_all: Score All Variables Using a Configuration Table

View source: R/scoring.R

score_allR Documentation

Score All Variables Using a Configuration Table

Description

Applies the appropriate scoring function to each soil variable according to a configuration table produced by make_config. This is the primary data-preparation step before computing any Soil Quality Index.

Usage

score_all(data, config, group_cols = "LandUse", custom_fns = list())

Arguments

data

A data frame containing the soil variables.

config

A sqi_config data frame (see make_config).

group_cols

Character vector of grouping column names to preserve unchanged. Default is "LandUse".

custom_fns

A named list of functions for variables with type = "custom". Names must match the variable column in config.

Value

A data frame with the same structure as data, but with each variable column replaced by its 0–1 score. Group columns are preserved unchanged.

References

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

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"))
head(scored)


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