Generate Monte Carlo Simulations and calculate carbon stock for all pools
Source:R/fct_combine_mcs_cpools.R
fct_combine_mcs_cpools.Rd
TBD
Value
A data frame with N simulations of each carbon pool and associated factors and the resulting total carbon stock in tCO2/ha.
Examples
library(dplyr)
library(readxl)
library(mocaredd)
path <- system.file("extdata/example1-4pools.xlsx", package = "mocaredd")
usr <- read_xlsx(path = path, sheet = "user_inputs", na = "NA")
cs <- read_xlsx(path = path, sheet = "c_stocks", na = "NA")
cs_clean <- cs |> filter(!(is.na(c_value) & is.na(c_pdf_a)))
c_sub <- cs_clean |> filter(lu_id == "ev_wet_closed")
#> Error in filter(cs_clean, lu_id == "ev_wet_closed"): ℹ In argument: `lu_id == "ev_wet_closed"`.
#> Caused by error:
#> ! object 'lu_id' not found
res <- fct_combine_mcs_cpools(.c_sub = c_sub, .usr = usr)
#> Error: object 'c_sub' not found
hist(res$C_all)
#> Error: object 'res' not found
round(median(res$C_all))
#> Error: object 'res' not found