% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/key-trace-format.R
\name{key_trace_table}
\alias{key_trace_table}
\title{Flatten a classification key trace into a tabular form}
\usage{
key_trace_table(x)
}
\arguments{
\item{x}{A \code{\link{ClassificationResult}}, or the \code{trace} list
taken from one.}
}
\value{
A \code{data.frame} with one row per trace step and columns:
  \describe{
    \item{\code{phase}}{Key phase / level the step belongs to (e.g.
      \code{"orders"}, \code{"subgrupos"}); empty for the flat WRB trace.}
    \item{\code{code}}{Taxon or attribute code.}
    \item{\code{name}}{Taxon or attribute name (or attribute value).}
    \item{\code{status}}{One of \code{"passed"}, \code{"failed"},
      \code{"indeterminate"} (a test that could not be evaluated for want of
      data), \code{"selected"} (the taxon assigned at a level), or
      \code{"info"} (a family attribute or label, not a pass/fail test).}
    \item{\code{missing}}{Comma-separated attributes that were missing for
      the step (empty when none).}
    \item{\code{n_missing}}{Integer count of missing attributes.}
  }
  A zero-row data frame with those columns when the trace is empty.
}
\description{
Normalises the system-dependent decision trace carried by a
\code{\link{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 (\code{print()}, the
HTML and PDF reports, the Shiny app) can render the trace uniformly.
}
\examples{
res <- classify_sibcs(make_ferralsol_canonical())
head(key_trace_table(res))
}
