Learn R Programming

fb4package (version 2.0.0)

assign_energy_components: Fill energy budget components from a named source list

Description

Internal helper that populates the estimate and se slots of several energy components inside a budget result list. Avoids repeating the same assignment pattern across population, individual, and TMB branches of get_energy_budget_uncertainty().

Usage

assign_energy_components(budget, src, mapping, idx = NULL)

Value

The updated budget list.

Arguments

budget

Named list with one sub-list per energy component, each containing at least estimate and se slots.

src

Named list (or data frame column) that holds the raw <prefix>_est / <prefix>_se values.

mapping

Named character vector mapping component names (keys) to source field prefixes (values), e.g. c(consumption_energy = "mean_total_consumption", ...).

idx

Integer index used for vector extraction (individual branch). NULL for scalar extraction (population / TMB branches).