
Plot each compartment's own factor breakdown, rolling mean
Source:R/decomposition_analysis.R
plot_compart_factor_roll.RdSame as plot_compart_factor_yearly(), but smooths each
year's own additive contribution with a centered rolling mean
(window years wide, NA-padded at the edges) before plotting, one
panel per compartment.
Usage
plot_compart_factor_roll(
cropland = NULL,
semi_natural = NULL,
manure = NULL,
urban = NULL,
window = 10
)Arguments
- cropland
A tibble from
decompose_cropland_surplus(). IfNULL, computed automatically (slow).- semi_natural
A tibble from
decompose_semi_natural_surplus(). IfNULL, computed automatically (slow).- manure
A tibble from
decompose_manure_losses(). IfNULL, computed automatically (slow).- urban
A tibble from
decompose_urban_losses(). IfNULL, computed automatically (slow).- window
Width of the centered rolling-mean window, in years. Default
10.
Examples
# `window` must not exceed the number of periods available per factor.
lmdi <- tibble::tribble(
~period, ~factor_label, ~component_type, ~additive,
"1861-1862", "N surplus", "target", 20000,
"1861-1862", "Size", "factor", 9000,
"1862-1863", "N surplus", "target", 10000,
"1862-1863", "Size", "factor", 5000,
"1863-1864", "N surplus", "target", 12000,
"1863-1864", "Size", "factor", 6000
)
plots <- plot_compart_factor_roll(lmdi, lmdi, lmdi, lmdi, window = 3)