From e740d8813ba4dcb5c9e5a2c59616f21a26336fcc Mon Sep 17 00:00:00 2001 From: Ben Young Date: Fri, 14 Jun 2024 13:41:32 -0400 Subject: [PATCH] fix error in assigning factors to CO2e flows #281 --- R/BuildModel.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/BuildModel.R b/R/BuildModel.R index 3e4591b5..3bc017be 100644 --- a/R/BuildModel.R +++ b/R/BuildModel.R @@ -285,9 +285,11 @@ createCfromFactorsandBflows <- function(factors,B_flows) { C[, flows_inBnotC] <- 0 C[is.na(C)] <- 0 - # Make sure CO2e flows are characterized (see issue #281) - f <- B_flows[!(B_flows %in% factors$Flow) & grepl("kg CO2e", B_flows)] - C[, f] <- 1 + if("Greenhouse Gases" %in% factors$Indicator) { + # Make sure CO2e flows are characterized (see issue #281) + f <- B_flows[!(B_flows %in% factors$Flow) & grepl("kg CO2e", B_flows)] + C["Greenhouse Gases", f] <- 1 + } # Filter and resort model C flows and make it into a matrix C <- as.matrix(C[, B_flows]) return(C)