Calculate emissions based on arithmetic means
Source:R/fct_arithmetic_mean.R
fct_arithmetic_mean.Rd
TBD
Arguments
- .ad
Activity Data input table for the shiny app (AD_lu_transitions)
- .cs
Carbon Stock input table for the shiny app (c_stocks)
- .usr
User inputs' table for the shiny app (user_inputs). Contains the number of iterations of the MCS, carbon fraction if needed and if truncated PDFs should be used when necessary.
- .time
the 'time' table from the tool input file (see template)
Value
A data frame with arithmetic mean of CO2 emissions for each land use transition, REDD+ activity or emission reductions level.
Examples
library(readxl)
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
library(mocaredd)
path <- system.file("extdata/example1-4pools.xlsx", package = "mocaredd")
cs <- read_xlsx(path = path, sheet = "c_stocks", na = "NA")
ad <- read_xlsx(path = path, sheet = "AD_lu_transitions", na = "NA")
usr <- read_xlsx(path = path, sheet = "user_inputs", na = "NA")
time <- read_xlsx(path = path, sheet = "time_periods", na = "NA")
#ad_clean <- ad |> dplyr::filter(!is.na(trans_area) | !is.na(trans_pdf_a))
#cs_clean <- cs |> dplyr::filter(!is.na(c_value) | !is.na(c_pdf_a))
time_clean <- time |> dplyr::mutate(nb_years = year_end - year_start + 1)
res <- fct_arithmetic_mean(.ad = ad, .cs = cs, .usr = usr, .time = time_clean)
#> Error in pmap(combi, function(period, lu) { c_sub <- filter(.cs, .data$c_period == period, .data$c_lu_id == lu) c_check <- fct_check_pool(.c_sub = c_sub, .c_unit = .usr$c_unit, .c_fraction = .usr$c_fraction)}): could not find function "pmap"
head(res$emissions)
#> Error: object 'res' not found
res$gg_emissions
#> Error: object 'res' not found