From bca5f3ff656542ea5c79a48536fc96adfbafe871 Mon Sep 17 00:00:00 2001 From: Jackson Hoffart Date: Mon, 18 Mar 2024 14:37:28 +0100 Subject: [PATCH] fix failing test --- R/join_abcd_scenario.R | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/R/join_abcd_scenario.R b/R/join_abcd_scenario.R index 24ce516b..3f083eca 100644 --- a/R/join_abcd_scenario.R +++ b/R/join_abcd_scenario.R @@ -53,8 +53,12 @@ join_abcd_scenario <- function(data, abcd <- add_green_technologies_to_abcd(abcd, scenario) } - abcd <- dplyr::filter(abcd, .data[["year"]] >= min(scenario[["year"]])) - scenario <- dplyr::filter(scenario, .data[["year"]] >= min(abcd[["year"]])) + abcd <- abcd %>% + arrange(.data[["year"]]) %>% + mutate( + .start_year = first(.data[["year"]]), + .by = c("name_company", "sector", "plant_location") + ) abcd_wide <- tidyr::pivot_wider( abcd, @@ -92,6 +96,10 @@ join_abcd_scenario <- function(data, values_from = "value" ) + data <- data %>% + dplyr::filter(.data[["year"]] >= .data[[".start_year"]]) %>% + dplyr::mutate(.start_year = NULL) + out <- data %>% mutate(plant_location = tolower(.data$plant_location)) %>% inner_join(