diff --git a/NAMESPACE b/NAMESPACE index 372a510..a94bb08 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -112,23 +112,14 @@ export(summarise_variable_counts) export(validate_predictions) export(validate_predictions_df_blue_tit) export(variance_box_cox) -import(NatParksPalettes) -import(broom) -import(broom.mixed) -import(cli) import(dplyr) -import(forcats) -import(ggforestplot) import(ggplot2) import(lme4) import(metafor) -import(purrr) -import(rlang) -import(see) -import(stringr) -import(tidyr) importFrom(EnvStats,stat_n_text) +importFrom(NatParksPalettes,scale_color_natparks_d) importFrom(betapart,beta.pair) +importFrom(broom,tidy) importFrom(broom.mixed,tidy) importFrom(cli,cli_abort) importFrom(cli,cli_alert) @@ -191,12 +182,14 @@ importFrom(purrr,exec) importFrom(purrr,flatten_dbl) importFrom(purrr,is_scalar_vector) importFrom(purrr,keep) +importFrom(purrr,keep_at) importFrom(purrr,list_c) importFrom(purrr,list_flatten) importFrom(purrr,list_rbind) importFrom(purrr,map) importFrom(purrr,map2) importFrom(purrr,map_chr) +importFrom(purrr,map_dfr) importFrom(purrr,map_if) importFrom(purrr,map_int) importFrom(purrr,map_lgl) @@ -206,6 +199,8 @@ importFrom(purrr,possibly) importFrom(purrr,reduce) importFrom(purrr,reduce2) importFrom(purrr,set_names) +importFrom(purrr,simplify) +importFrom(purrr,transpose) importFrom(readr,read_csv) importFrom(recipes,juice) importFrom(recipes,prep) @@ -214,18 +209,27 @@ importFrom(recipes,step_mutate) importFrom(recipes,step_naomit) importFrom(recipes,tidy) importFrom(recipes,update_role) +importFrom(rlang,"!!") +importFrom(rlang,":=") importFrom(rlang,as_function) +importFrom(rlang,as_string) importFrom(rlang,caller_env) importFrom(rlang,enquo) importFrom(rlang,ensym) importFrom(rlang,exec) importFrom(rlang,expr) +importFrom(rlang,exprs) +importFrom(rlang,f_lhs) importFrom(rlang,inject) +importFrom(rlang,is_call) +importFrom(rlang,is_list) importFrom(rlang,is_na) importFrom(rlang,is_null) importFrom(rlang,na_chr) importFrom(rlang,new_formula) importFrom(sae,bxcx) +importFrom(see,geom_jitter2) +importFrom(see,scale_fill_material_d) importFrom(see,theme_modern) importFrom(stringr,str_detect) importFrom(stringr,str_remove) @@ -237,14 +241,18 @@ importFrom(tibble,enframe) importFrom(tibble,rownames_to_column) importFrom(tibble,tibble) importFrom(tidyr,any_of) +importFrom(tidyr,drop_na) importFrom(tidyr,hoist) importFrom(tidyr,nest) importFrom(tidyr,pivot_longer) importFrom(tidyr,pivot_wider) +importFrom(tidyr,separate) +importFrom(tidyr,tibble) importFrom(tidyr,unite) importFrom(tidyr,unnest) importFrom(tidyr,unnest_longer) importFrom(tidyselect,all_of) +importFrom(tidyselect,where) importFrom(timetk,step_box_cox) importFrom(workflows,add_model) importFrom(workflows,add_recipe) diff --git a/R/filt_multivar_MA.R b/R/filt_multivar_MA.R index 89c1480..4101e66 100644 --- a/R/filt_multivar_MA.R +++ b/R/filt_multivar_MA.R @@ -14,7 +14,7 @@ #' @importFrom lme4 lmer #' @importFrom pointblank test_col_vals_gte expect_col_exists #' @import dplyr -#' @importFrom purrr list_flatten list_c +#' @importFrom purrr list_flatten list_c transpose #' @importFrom tibble enframe #' @importFrom tidyr unite #' @importFrom cli cli_alert_info cli_bullets cli_h2 style_italic diff --git a/R/fit_boxcox_ratings_cat.R b/R/fit_boxcox_ratings_cat.R index d31e6db..e54c382 100644 --- a/R/fit_boxcox_ratings_cat.R +++ b/R/fit_boxcox_ratings_cat.R @@ -42,7 +42,7 @@ fit_boxcox_ratings_cat <- function(data, outcome, outcome_var, interceptless = F ) # ----- Fit model ----- - cli::cli_h2(c("Fitting {.fn lmer} with categorical ratings predictor {.arg PublishableAsIs} on Box-Cox transformed outcome: outcome: {.val {outcome}}")) + cli::cli_h2(c("Fitting {.fn lmer} with categorical ratings predictor {.arg PublishableAsIs} on Box-Cox transformed {.arg outcome}: {.arg {rlang::enexpr(outcome)}}")) data_tbl <- data %>% diff --git a/R/fit_boxcox_ratings_cont.R b/R/fit_boxcox_ratings_cont.R index 9529b44..61ba76a 100644 --- a/R/fit_boxcox_ratings_cont.R +++ b/R/fit_boxcox_ratings_cont.R @@ -29,7 +29,7 @@ fit_boxcox_ratings_cont <- function(data, outcome, outcome_var, ..., env = rlang ) # ----- Fit model ----- - cli::cli_h2(c("Fitting {.fn lmer} with continuous ratings predictor {.arg RateAnalysis} on Box-Cox transformed outcome: {.val {outcome}}")) + cli::cli_h2(c("Fitting {.fn lmer} with continuous ratings predictor {.arg RateAnalysis} on Box-Cox transformed {.arg outcome}: {.arg {rlang::enexpr(outcome)}}")) data_tbl <- # TODO, consider extracting unnesting outside of this fn. data %>% select( diff --git a/R/meta_analyse_datasets.R b/R/meta_analyse_datasets.R index 90da72a..b2cf925 100644 --- a/R/meta_analyse_datasets.R +++ b/R/meta_analyse_datasets.R @@ -19,6 +19,7 @@ #' @importFrom stringr str_detect #' @importFrom purrr map_chr map2 map possibly pmap list_c map_lgl #' @import dplyr +#' @importFrom tidyselect where #' @importFrom cli cli_h1 cli_abort #' @importFrom rlang na_chr is_null na_chr is_list is_call exprs f_lhs as_string #' @importFrom pointblank expect_col_exists @@ -197,7 +198,7 @@ meta_analyse_datasets <- function(data, outcome_variable = NULL, outcome_SE = NU purrr::map( .x = effects_analysis, .f = ~ fit_boxcox_ratings_cont( - .data = .x, + data = .x, outcome = box_cox_abs_deviation_score_estimate, outcome_var = box_cox_var ) @@ -206,7 +207,7 @@ meta_analyse_datasets <- function(data, outcome_variable = NULL, outcome_SE = NU purrr::map( .x = effects_analysis, .f = ~ poss_fit_boxcox_ratings_cat( - .data = .x, + data = .x, outcome = box_cox_abs_deviation_score_estimate, outcome_var = box_cox_var, interceptless = FALSE @@ -216,7 +217,7 @@ meta_analyse_datasets <- function(data, outcome_variable = NULL, outcome_SE = NU purrr::map( .x = effects_analysis, .f = ~ poss_fit_boxcox_ratings_cat( - .data = .x, + data = .x, outcome = box_cox_abs_deviation_score_estimate, outcome_var = box_cox_var, interceptless = TRUE @@ -268,9 +269,10 @@ meta_analyse_datasets <- function(data, outcome_variable = NULL, outcome_SE = NU out <- out %>% # replace any NULL values with NA - mutate(across(everything(), - .fns = ~ coalesce(.x, list(NA)) - )) + mutate( + across(where(is.list), + .fns = ~ coalesce(.x, list(NA))) + ) return(out) } diff --git a/_targets.R b/_targets.R index 605a98c..b545f11 100644 --- a/_targets.R +++ b/_targets.R @@ -260,18 +260,27 @@ list(tarchetypes::tar_file_read(name = euc_reviews, dataset_log_transform = "eucalyptus") %>% generate_yi_subsets() %>% #TODO: must be run after prepare_response_variables?? apply_VZ_exclusions( - VZ_colname = list("eucalyptus" = "std.error_log", + VZ_colname = list("eucalyptus" = "se_log", "blue tit" = "VZ"), VZ_cutoff = 3) %>% - generate_exclusion_subsets() %>% #TODO: runs on ManyEcoEvo that contains Zr and yi results. - generate_outlier_subsets(outcome_variable = - list(dataset = list("eucalyptus" = "mean_log", - "blue tit" = "Z")), - n_min = -3, - n_max = -3, - ignore_subsets = NULL) %>% + generate_exclusion_subsets() %>% #TODO: runs on ManyEcoEvo that contains Zr and yi results; DELETE, not needed + generate_outlier_subsets( + outcome_variable = + list(dataset = + list("eucalyptus" = "mean_log", + "blue tit" = "Z")), + n_min = -3, + n_max = -3, + ignore_subsets = NULL) %>% compute_MA_inputs() %>% - meta_analyse_datasets(filter_vars = NULL) #TODO requires col exclusion_set from generate_exclusion_subsets() but don't need that fun in this pipeline anymore + meta_analyse_datasets( + outcome_variable = + list(dataset = + list("eucalyptus" = "mean_log", "blue tit" = "Z")), + outcome_SE = + list(dataset = + list("eucalyptus" = "se_log", "blue tit" = "VZ")), + filter_vars = rlang::exprs(exclusion_set == "complete")) #TODO requires col exclusion_set from generate_exclusion_subsets() but don't need that fun in this pipeline anymore ), targets::tar_target(name = ManyEcoEvo_yi_viz, command = make_viz(ManyEcoEvo_yi_results)),