From b1d5662ab06a36d04c0c5638c9a896a344d454f8 Mon Sep 17 00:00:00 2001 From: Jackson Hoffart Date: Mon, 25 Mar 2024 17:01:57 +0100 Subject: [PATCH] only skip missing val check when necessary --- R/summarize_weighted_production.R | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/R/summarize_weighted_production.R b/R/summarize_weighted_production.R index 52fe1d64..c8c476ff 100644 --- a/R/summarize_weighted_production.R +++ b/R/summarize_weighted_production.R @@ -189,7 +189,21 @@ summarize_unweighted_emission_factor <- function(data, ...) { calculate_weighted_loan_metric <- function(data, metric) { check_crucial_names(data, c(metric, "loan_weight")) - walk_("loan_weight", ~ check_no_value_is_missing(data, .x)) + + allowed_missing_vals <- c( + "production", + "production_target", + "technology_share", + "technology_share_target" + ) + + if (metric %in% allowed_missing_vals) { + no_missing_vals <- "loan_weight" + } else { + no_missing_vals <- c("loan_weight", metric) + } + + walk_(no_missing_vals, ~ check_no_value_is_missing(data, .x)) data %>% mutate(