Skip to content

Commit

Permalink
#1968 compute_multiple_vars: fix R-CMD checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Jul 28, 2023
1 parent e8c533f commit 2abae76
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 40 deletions.
20 changes: 12 additions & 8 deletions R/derive_adeg_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,14 @@ derive_param_qtc <- function(dataset,
filter = !!filter,
parameters = c(qt_code, rr_code),
by_vars = by_vars,
analysis_value = compute_qtc(
qt = !!sym(paste0("AVAL.", qt_code)),
rr = !!sym(paste0("AVAL.", rr_code)),
method = !!method
),
set_values_to = set_values_to
set_values_to = exprs(
AVAL = compute_qtc(
qt = !!sym(paste0("AVAL.", qt_code)),
rr = !!sym(paste0("AVAL.", rr_code)),
method = !!method
),
!!!set_values_to
)
)
}

Expand Down Expand Up @@ -336,8 +338,10 @@ derive_param_rr <- function(dataset,
filter = !!filter,
parameters = c(hr_code),
by_vars = by_vars,
analysis_value = compute_rr(!!sym(paste0("AVAL.", hr_code))),
set_values_to = set_values_to
set_values_to = exprs(
AVAL = compute_rr(!!sym(paste0("AVAL.", hr_code))),
!!!set_values_to
)
)
}

Expand Down
18 changes: 12 additions & 6 deletions R/derive_advs_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ derive_param_map <- function(dataset,
filter = !!filter,
parameters = c(sysbp_code, diabp_code, hr_code),
by_vars = by_vars,
analysis_value = !!analysis_value,
set_values_to = set_values_to
set_values_to = exprs(
AVAL = !!analysis_value,
!!!set_values_to
)
)
}

Expand Down Expand Up @@ -427,8 +429,10 @@ derive_param_bsa <- function(dataset,
filter = !!filter,
parameters = parameters,
by_vars = by_vars,
analysis_value = !!bsa_formula,
set_values_to = set_values_to,
set_values_to = exprs(
AVAL = !!bsa_formula,
!!!set_values_to
),
constant_parameters = constant_parameters,
constant_by_vars = constant_by_vars
)
Expand Down Expand Up @@ -712,8 +716,10 @@ derive_param_bmi <- function(dataset,
filter = !!filter,
parameters = parameters,
by_vars = by_vars,
analysis_value = !!bmi_formula,
set_values_to = set_values_to,
set_values_to = exprs(
AVAL = !!bmi_formula,
!!!set_values_to
),
constant_parameters = constant_parameters,
constant_by_vars = constant_by_vars
)
Expand Down
7 changes: 4 additions & 3 deletions R/derive_param_computed.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
#'
#' @examples
#' library(tibble)
#' library(dplyr)
#' library(lubridate)
#'
#' # Example 1: Derive MAP
Expand Down Expand Up @@ -438,14 +439,14 @@ assert_parameters_argument <- function(parameters, optional = TRUE) {
#'
#' *Permitted Values:* A character vector of `PARAMCD` values or a list of expressions
#'
#' @param analysis_value
#' @param set_values_to
#'
#' All variables of the form `<variable>.<parameter>` like `AVAL.WEIGHT` are
#' added to the input dataset. They are set to the value of the variable for
#' the parameter. E.g., `AVAL.WEIGHT` is set to the value of `AVAL` where
#' `PARAMCD == "WEIGHT"`.
#'
#' *Permitted Values:* An unquoted expression
#' *Permitted Values:* A list of expressions
#'
#' @param filter Filter condition used for restricting the input dataset
#'
Expand Down Expand Up @@ -536,7 +537,7 @@ get_hori_data <- function(dataset,
)

# horizontalize data, e.g., AVAL for PARAMCD = "PARAMx" -> AVAL.PARAMx
analysis_vars <- flatten(map(set_values_to, extract_vars))
analysis_vars <- flatten(map(unname(set_values_to), extract_vars))
analysis_vars_chr <- vars2chr(analysis_vars)
multi_dot_names <- str_count(analysis_vars_chr, "\\.") > 1
if (any(multi_dot_names)) {
Expand Down
6 changes: 4 additions & 2 deletions R/derive_param_framingham.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ derive_param_framingham <- function(dataset,
diabetfl,
trthypfl
),
analysis_value = !!analysis_value,
set_values_to = set_values_to
set_values_to = exprs(
AVAL = !!analysis_value,
!!!set_values_to
)
)
}
6 changes: 4 additions & 2 deletions R/derive_param_wbc_abs.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ derive_param_wbc_abs <- function(dataset,
diff_code
),
by_vars = by_vars,
analysis_value = !!analysis_value,
set_values_to = set_values_to
set_values_to = exprs(
AVAL = !!analysis_value,
!!!set_values_to
)
) %>%
filter(PARAMCD == !!set_values_to$PARAMCD) %>%
select(-starts_with("temp_"))
Expand Down
12 changes: 8 additions & 4 deletions inst/templates/ad_adex.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,17 @@ adex <- adex %>%
variable_params = list(
params(
parameters = c("TDOSE", "TDURD"),
analysis_value = (AVAL.TDOSE / AVAL.TDURD),
set_values_to = exprs(PARAMCD = "AVDDSE")
set_values_to = exprs(
AVAL = (AVAL.TDOSE / AVAL.TDURD),
PARAMCD = "AVDDSE"
)
),
params(
parameters = c("PDOSE", "PDURD"),
analysis_value = (AVAL.PDOSE / AVAL.PDURD),
set_values_to = exprs(PARAMCD = "PAVDDSE")
set_values_to = exprs(
AVAL = (AVAL.PDOSE / AVAL.PDURD),
PARAMCD = "PAVDDSE"
)
)
),
by_vars = exprs(
Expand Down
5 changes: 3 additions & 2 deletions man/derive_param_computed.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/get_hori_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/testthat/test-derive_advs_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ test_that("derive_param_bmi Test 38: Derive BMI where height is measured only on
input,
by_vars = exprs(USUBJID, VISIT),
parameters = "WEIGHT",
analysis_value = AVAL.WEIGHT / (AVAL.HEIGHT / 100)^2,
set_values_to = exprs(
AVAL = AVAL.WEIGHT / (AVAL.HEIGHT / 100)^2,
PARAMCD = "BMI",
PARAM = "Body Mass Index (kg/m^2)",
AVALU = "kg/m^2"
Expand Down Expand Up @@ -859,11 +859,11 @@ test_that("derive_param_bsa Test 51: Derive BSA where height is measured only on
input,
by_vars = exprs(USUBJID, VISIT),
parameters = "WEIGHT",
analysis_value = compute_bsa(
height = AVAL.HEIGHT, weight = AVAL.WEIGHT,
method = "Mosteller"
),
set_values_to = exprs(
AVAL = compute_bsa(
height = AVAL.HEIGHT, weight = AVAL.WEIGHT,
method = "Mosteller"
),
PARAMCD = "BSA",
PARAM = "Body Surface Area (m^2)",
AVALU = "m^2"
Expand Down
2 changes: 1 addition & 1 deletion vignettes/bds_finding.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,8 @@ advs_ex3 <- derive_param_computed(
advs,
by_vars = exprs(USUBJID, VISIT, ATPT),
parameters = c("SYSBP", "DIABP"),
analysis_value = (AVAL.SYSBP - AVAL.DIABP) / 3 + AVAL.DIABP,
set_values_to = exprs(
AVAL = (AVAL.SYSBP - AVAL.DIABP) / 3 + AVAL.DIABP,
PARAMCD = "MAP2",
PARAM = "Mean Arterial Pressure 2 (mmHg)"
)
Expand Down

0 comments on commit 2abae76

Please sign in to comment.