
Prepare production data for livestock emission calculations.
Source:R/livestock_bridge.R
prepare_livestock_emissions.RdBridge between build_primary_production() output and the
livestock emission functions. Maps species codes to names,
converts area codes to ISO3, extracts milk and meat yields,
and optionally expands herds into GLEAM cohorts.
Any extra columns present in the input (e.g., weight,
diet_quality, fat_percent) are preserved and flow
through to the emission functions automatically.
Arguments
- data
A tibble from
build_primary_production()with columnsitem_cbs_code,unit,value, and optionallyyear,area_code,live_anim_code.- expand_cohorts
Logical. If
TRUE, distributes herds across GLEAM cohorts and production systems viacalculate_cohorts_systems(). DefaultFALSE.Optional dataframe with custom system shares. Passed to
calculate_cohorts_systems().
Value
A tibble with columns species, heads, iso3
(if area_code present), and optionally
milk_yield_kg_day, meat_yield_t_head, cohort columns,
plus all extra columns from the input.
Examples
tibble::tibble(
item_cbs_code = 961,
unit = "heads",
value = 5000,
area_code = 79L
) |>
prepare_livestock_emissions()
#> # A tibble: 1 × 6
#> item_cbs_code unit heads area_code species iso3
#> <dbl> <chr> <dbl> <dbl> <chr> <chr>
#> 1 961 heads 5000 79 Cattle, non-dairy DEU