
Flatten a classification key trace into a tabular form
Source:R/key-trace-format.R
key_trace_table.RdNormalises the system-dependent decision trace carried by a
ClassificationResult into a single, ordered data frame of
display rows. WRB 2022 stores a flat list of reference-soil-group test
steps; the hierarchical SiBCS and USDA keys store a nested list of phases
(orders, suborders, great groups, subgroups, family, ...), each holding
candidate steps, an assigned-taxon record, family attributes, or a bare
label. This function walks all of those shapes and returns one row per step,
in the order the key was evaluated, so every consumer (print(), the
HTML and PDF reports, the Shiny app) can render the trace uniformly.
Arguments
- x
A
ClassificationResult, or thetracelist taken from one.
Value
A data.frame with one row per trace step and columns:
phaseKey phase / level the step belongs to (e.g.
"orders","subgrupos"); empty for the flat WRB trace.codeTaxon or attribute code.
nameTaxon or attribute name (or attribute value).
statusOne of
"passed","failed","indeterminate"(a test that could not be evaluated for want of data),"selected"(the taxon assigned at a level), or"info"(a family attribute or label, not a pass/fail test).missingComma-separated attributes that were missing for the step (empty when none).
n_missingInteger count of missing attributes.
A zero-row data frame with those columns when the trace is empty.
Examples
res <- classify_sibcs(make_ferralsol_canonical())
head(key_trace_table(res))
#> phase code name status missing n_missing
#> 1 ordens O Organossolos failed 0
#> 2 ordens R Neossolos failed 0
#> 3 ordens V Vertissolos indeterminate slickensides 1
#> 4 ordens E Espodossolos indeterminate al_ox_pct, fe_ox_pct 2
#> 5 ordens S Planossolos failed 0
#> 6 ordens G Gleissolos indeterminate redoximorphic_features_pct 1