Skip to content

Commit

Permalink
#88 rm unused args in process_response() and replace with ...
Browse files Browse the repository at this point in the history
- #102 Add `@details` section for `process_response()` and add heading for `@details` in `standardise_response()`
  • Loading branch information
egouldo committed Aug 14, 2024
1 parent f5d7c9a commit 4d556d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
12 changes: 4 additions & 8 deletions R/prepare_response_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ prepare_response_variables <- function(ManyEcoEvo,
if (!is.null(dataset_standardise)) {
stopifnot(is.character(dataset_standardise))
stopifnot(length(dataset_standardise) >= 1)
stopifnot(length(dataset_standardise) == length(unique(ManyEcoEvo$dataset)))
stopifnot(length(dataset_standardise) <= length(unique(ManyEcoEvo$dataset)))
match.arg(dataset_standardise, choices = ManyEcoEvo$dataset, several.ok = TRUE)
}

Expand Down Expand Up @@ -84,10 +84,6 @@ prepare_response_variables <- function(ManyEcoEvo,
))
} else {

process_response <- function(dat){
dat #TODO replace dummy function with actual function
}

datasets_to_standardise <- tibble(
dataset = dataset_standardise,
fns = list(standardise_response)
Expand All @@ -100,12 +96,12 @@ prepare_response_variables <- function(ManyEcoEvo,
out <- out %>%
ungroup() %>%
left_join(datasets_to_standardise, by = "dataset") %>%
mutate(fns = coalesce(fns, list(process_response)),
data = pmap(.l = .,
mutate(fns = coalesce(fns, list(process_response))) %>%
mutate(data = pmap(.l = .,
.f = pmap_prepare_response,
estimate_type = estimate_type,
param_table = param_table)) %>%
select(-fns)
select(-fns) #TODO drop ci cols or not??
}
return(out)
}
19 changes: 14 additions & 5 deletions R/standardise_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ NULL
#' Standardise Response Variable
#' @return A tibble of analyst data with standardised values contained in a list-column called 'back_transformed_data'
#' @details
#' # `standardise_response()`
#'
#' When the `estimate_type` is `"Zr"`, [standardise_response()] standardises
#' effect-sizes with [est_to_zr()], assuming that the `beta_estimate` and
#' `beta_SE` values have already been back-transformed to the appropriate scale. #TODO check this.
Expand Down Expand Up @@ -120,10 +122,18 @@ standardise_response <- function(dat,
#' @description
#' This function generates the response data for meta-analysis without standardising the effect sizes / out-of-sample predictions.
#' @describeIn process_analyst_data Process response data for meta-analysis but do not standardise effect-sizes
process_response <- function(dat,
estimate_type = NULL,
param_table = NULL,
dataset = NULL){ #TODO what to do about args in pmap_prepare_response? allow ... args in fns(x,y,z, ...)?
#' @details
#' # `process_response()`
#'
#' Formats tibbles in the list-column `back_transformed_data` to ensure that the
#' correct columns are present for meta-analysis, matching the outputs of
#' [standardise_response()]. For blue tit data `dat$back_transformed_data$fit`
#' and for eucalyptus data, `dat$back_transformed_data$estimate` is renamed `Z`.
#' `se.fit` is renamed `VZ`.
#' @import dplyr
#' @import purrr
#' @import tidyr
process_response <- function(dat, ...){

Z_names_lookup <- c(Z = "estimate", #blue tit
Z = "fit", #eucalyptus
Expand All @@ -135,5 +145,4 @@ process_response <- function(dat,
rename,
any_of(Z_names_lookup)),
params = NA)
#TODO replace dummy function with actual function
}

0 comments on commit 4d556d0

Please sign in to comment.