1313# ' transition, REDD+ activity or emission reductions level.
1414# '
1515# ' @importFrom rlang .data
16- # ' @importFrom magrittr %>%
1716# '
1817# ' @examples
1918# ' library(readxl)
2019# ' library(dplyr)
2120# ' library(mocaredd)
2221# '
23- # ' cs <- read_xlsx(
24- # ' system.file("extdata/example1.xlsx", package = "mocaredd"),
25- # ' sheet = "c_stocks",
26- # ' na = "NA"
27- # ' )
28- # ' ad <- read_xlsx(
29- # ' system.file("extdata/example1.xlsx", package = "mocaredd"),
30- # ' sheet = "AD_lu_transitions",
31- # ' na = "NA"
32- # ' )
33- # ' usr <- read_xlsx(
34- # ' system.file("extdata/example1.xlsx", package = "mocaredd"),
35- # ' sheet = "user_inputs",
36- # ' na = "NA"
37- # ' )
22+ # ' path <- system.file("extdata/example1-4pools.xlsx", package = "mocaredd")
23+ # '
24+ # ' cs <- read_xlsx(path = path, sheet = "c_stocks", na = "NA")
25+ # ' ad <- read_xlsx(path = path, sheet = "AD_lu_transitions", na = "NA")
26+ # ' usr <- read_xlsx(path = path, sheet = "user_inputs", na = "NA")
3827# '
3928# ' cs_clean <- cs |> filter(!is.na(c_value) | !is.na(c_pdf_a))
4029# '
@@ -80,7 +69,7 @@ fct_combine_mcs_E <- function(.ad, .cs, .usr){
8069 # print(x)
8170 # # !!
8271
83- ad_x <- .ad % > % dplyr :: filter(.data $ trans_id == x )
72+ ad_x <- .ad | > dplyr :: filter(.data $ trans_id == x )
8473 redd_x <- ad_x $ redd_activity
8574
8675 # # AD - Activity Data
@@ -134,9 +123,9 @@ fct_combine_mcs_E <- function(.ad, .cs, .usr){
134123 # dg_pool <- stringr::str_split(.usr$dg_pool, pattern = ",") |> purrr::map(stringr::str_trim) |> unlist()
135124 # dg_pool_i <- paste0(dg_pool, "_i")
136125 #
137- # combi <- combi %>%
138- # dplyr::rowwise() %>%
139- # dplyr::mutate(C_all_f = .data$DG_ratio_f * sum(!!!rlang::syms(dg_pool_i))) %>%
126+ # combi <- combi |>
127+ # dplyr::rowwise() |>
128+ # dplyr::mutate(C_all_f = .data$DG_ratio_f * sum(!!!rlang::syms(dg_pool_i))) |>
140129 # dplyr::ungroup()
141130 #
142131 # ## If degradation has unaffected pools, we identify them by difference and add them to final C stock
@@ -149,9 +138,9 @@ fct_combine_mcs_E <- function(.ad, .cs, .usr){
149138 # dg_expool <- paste0(setdiff(c_pools, dg_pool), "_i")
150139 #
151140 # if (length(dg_expool) > 0) {
152- # combi <- combi %>%
153- # dplyr::rowwise() %>%
154- # dplyr::mutate(C_all_f = .data$C_all_f + sum(!!!rlang::syms(dg_expool))) %>%
141+ # combi <- combi |>
142+ # dplyr::rowwise() |>
143+ # dplyr::mutate(C_all_f = .data$C_all_f + sum(!!!rlang::syms(dg_expool))) |>
155144 # dplyr::ungroup()
156145 # }
157146 # }
@@ -164,11 +153,11 @@ fct_combine_mcs_E <- function(.ad, .cs, .usr){
164153 # # END LOOP
165154
166155 # # Re-arrange columns and add EF and E (emissions at transition level)
167- tt <- mcs_trans % > %
156+ mcs_trans | >
168157 dplyr :: mutate(
169158 EF = round((.data $ C_all_i - .data $ C_all_f ) * 44 / 12 , 0 ),
170159 E_sim = round(.data $ AD * .data $ EF , 0 )
171- ) % > %
160+ ) | >
172161 # dplyr::mutate(dplyr::across(c(.data$E_sim, .data$AD, .data$EF, .data$C_all_i, .data$C_all_f))) |>
173162 dplyr :: select(
174163 " sim_no" , " redd_activity" , time_period = " trans_period" , " trans_id" ,
0 commit comments