From 9922d0cbd26a8465fe7f8d496181b1eeddf6aeb1 Mon Sep 17 00:00:00 2001 From: Karen Noiva Date: Mon, 25 Nov 2024 18:44:09 -0500 Subject: [PATCH] Update aggregate_impacts.R Fixed line in aggregate_impacts.R that was preventing model averages from being calculated --- R/aggregate_impacts.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/aggregate_impacts.R b/R/aggregate_impacts.R index e1933766..abf2b17c 100644 --- a/R/aggregate_impacts.R +++ b/R/aggregate_impacts.R @@ -429,7 +429,8 @@ aggregate_impacts <- function( ###### ** Model Averages ###### ### Average values across models - modTypes0 <- df_agg[["model_type"]] + # modTypes0 <- df_agg[["model_type"]] + modTypes0 <- df_agg |> pull(model_type) |> unique() |> tolower() has_modTypes <- modTypes0 |> length() has_gcm <- has_modTypes |> ifelse("gcm" %in% modTypes0, FALSE) if(aveModels & has_gcm){ @@ -438,7 +439,7 @@ aggregate_impacts <- function( ### Ungroup first df_agg <- df_agg |> ungroup() ### Group by columns - group0 <- groupByCols |> get_matches(y=c("model", yearCol0), matches=F) + group0 <- groupByCols |> get_matches(y="model" |> c(yearCol0), matches=F) group0 <- group0 |> c("year") ### Separate model types df_gcm <- df_agg |> filter(model_type |> tolower() == "gcm")