new_external_schema: Define a schema for external inventory workflows

new_external_schemaR Documentation

Define a schema for external inventory workflows

Description

Create a reusable "external_schema" object that records how source columns in an external inventory correspond to the standardized field names used by the basifoR external workflow. The schema can also store declared measurement units, default grouping levels, columns to preserve during processing, and auxiliary defaults that wrapper functions may reuse across repeated calls.

Usage

new_external_schema(colmap, 
    units = list(), levels = NULL, 
    keep_cols = NULL, 
    defaults = list())

Arguments

colmap

Named list mapping standardized variables to one or more candidate source column names in the input data.

units

Named list of declared units for standardized variables, usually entries such as list(d = "mm", h = "m").

levels

Optional character vector of default grouping variables for downstream summaries.

keep_cols

Optional character vector naming source columns that should be retained in downstream outputs.

defaults

Optional named list of auxiliary defaults or metadata that wrappers may reuse.

Details

The returned object is lightweight. It validates the basic

structure of the inputs, assigns class

c("external_schema", "list"), and leaves semantic

interpretation to downstream helpers such as

externalMetrics(), externalMetrics2Vol(), or

external_dendroMetrics().

Value

An object of class "external_schema" containing normalized colmap, units, levels, keep_cols, and defaults components, ready to pass to external workflow wrappers.

Author(s)

Wilson Lara [aut, cre] (ORCID: <https://orcid.org/0000-0003-3527-1380>), Cristobal Ordonez [aut] (ORCID: <https://orcid.org/0000-0001-5354-3760>), Aitor Vázquez-Veloso [aut] (ORCID: <https://orcid.org/0000-0003-0227-506X>), Felipe Bravo [aut] (ORCID: <https://orcid.org/0000-0001-7348-6695>)

Examples

sch <- new_external_schema(
    colmap = list(
        plot = c("plot_id", "plot"),
        species = c("species_code", "sp"),
        d = c("dbh_mm", "diameter_mm"),
        h = c("height_m", "h")
    ),
    units = list(d = "mm", h = "m"),
    levels = "plot",
    keep_cols = c("plot_id", "species_code"),
    defaults = list(selector = "priority")
)

class(sch)
sch$colmap$d
sch$units
sch$levels

basifoR documentation built on Aug. 26, 2026, 9:06 a.m.