From ff2e5990f0903a9513ad7f8855cbe75beb4d62e1 Mon Sep 17 00:00:00 2001 From: egouldo Date: Thu, 29 Aug 2024 18:14:10 +1000 Subject: [PATCH] bug!: #130 `meta_analyse_datasets()` failing for `ManyEcoEvo_results` - Added conditional behaviour for when character vector supplied - feat!: added arg checks #116 and cli output for when this condition is triggered --- But wasn't failing for `yi` because `yi` received `rlang::expressions()` while `Zr` call used single length character variable for `outcome_variable` and `outcome_SE` --- R/meta_analyse_datasets.R | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/R/meta_analyse_datasets.R b/R/meta_analyse_datasets.R index 056a634..d6d3085 100644 --- a/R/meta_analyse_datasets.R +++ b/R/meta_analyse_datasets.R @@ -101,16 +101,37 @@ meta_analyse_datasets <- function(data, outcome_variable = NULL, outcome_SE = NU if (any(str_detect(unique(data$estimate_type), pattern = "Zr"))) { outcome_variable <- "Zr" outcome_SE <- "VZr" + cli::cli_bullets( + c("i" = + "Assigning default {.arg outcome_variable} = {.val {outcome_variable}}", + "i" = + "Assigning default {.arg outcome_SE} = {.val {outcome_SE}}") + ) } else { outcome_variable <- "Z" outcome_SE <- "VZ" + cli::cli_bullets( + c("i" = + "Assigning default {.arg outcome_variable} = {.val {outcome_variable}}", + "i" = + "Assigning default {.arg outcome_SE} = {.val {outcome_SE}}") + ) } + data <- data %>% + ungroup %>% + mutate(outcome_colname = outcome_variable, + outcome_SE_colname = outcome_SE) + } else if (rlang::is_character(outcome_variable)) { + # Single value supplied + stopifnot(length(outcome_variable) == 1, + length(outcome_SE) == 1) + data <- data %>% ungroup %>% mutate(outcome_colname = outcome_variable, outcome_SE_colname = outcome_SE) } else { - # Argument supplied + # expressions argument supplied matched_formulae_outcome <- map(outcome_variable, ~ formulae_match(x = names(.x), y = .x))