From 6612e2325c415166056fcaa1286cc01739dea275 Mon Sep 17 00:00:00 2001 From: Zelos Zhu Date: Mon, 11 Sep 2023 06:23:22 -0400 Subject: [PATCH] Closes #2091 fixing deprecation messaging in `derive_param_doseint()` (#2092) * feat: #2091 did that work? * chore: #2091 address errors * fixed deprecation warning * deprecation for analysis_var --------- Co-authored-by: Zelos Zhu Co-authored-by: StefanThoma <40463122+StefanThoma@users.noreply.github.com> --- R/derive_param_computed.R | 19 +++++++++++-------- R/derive_param_doseint.R | 5 +++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/R/derive_param_computed.R b/R/derive_param_computed.R index fb86e3a7de..ac5b43314c 100644 --- a/R/derive_param_computed.R +++ b/R/derive_param_computed.R @@ -293,14 +293,6 @@ derive_param_computed <- function(dataset = NULL, constant_parameters = NULL, keep_nas = FALSE) { assert_vars(by_vars) - if (!missing(analysis_var)) { - deprecate_warn( - "0.12.0", - "derive_param_computed(analysis_var = )", - "derive_param_computed(set_values_to = )" - ) - } - analysis_var <- assert_symbol(enexpr(analysis_var)) assert_vars(constant_by_vars, optional = TRUE) assert_data_frame(dataset, required_vars = by_vars, optional = TRUE) assert_data_frame(dataset_add, optional = TRUE) @@ -310,6 +302,16 @@ derive_param_computed <- function(dataset = NULL, assert_param_does_not_exist(dataset, set_values_to$PARAMCD) } assert_logical_scalar(keep_nas) + ### BEGIN DEPRECATION + if (!missing(analysis_var)) { + deprecate_warn( + "0.12.0", + "derive_param_computed(analysis_var = )", + "derive_param_computed(set_values_to = )" + ) + } + analysis_var <- assert_symbol(enexpr(analysis_var)) + if (!missing(analysis_value)) { deprecate_warn( "0.12.0", @@ -318,6 +320,7 @@ derive_param_computed <- function(dataset = NULL, ) set_values_to <- exprs(!!analysis_var := !!enexpr(analysis_value), !!!set_values_to) } + ### END DEPRECATION parameters <- assert_parameters_argument(parameters) constant_parameters <- assert_parameters_argument(constant_parameters, optional = TRUE) diff --git a/R/derive_param_doseint.R b/R/derive_param_doseint.R index 6e25e1eac0..016af0088b 100644 --- a/R/derive_param_doseint.R +++ b/R/derive_param_doseint.R @@ -131,6 +131,8 @@ derive_param_doseint <- function(dataset, aval_tadm <- sym(paste0("AVAL.", tadm_code)) aval_tpdm <- sym(paste0("AVAL.", tpadm_code)) + analysis_value <- exprs(AVAL = !!aval_tadm / !!aval_tpdm * 100) + # handle 0 doses planned if needed if (zero_doses == "100") { update_aval <- exprs( @@ -151,7 +153,6 @@ derive_param_doseint <- function(dataset, filter = !!filter, parameters = c(tadm_code, tpadm_code), by_vars = by_vars, - analysis_value = (!!aval_tadm / !!aval_tpdm * 100), - set_values_to = expr_c(set_values_to, update_aval) + set_values_to = expr_c(set_values_to, analysis_value, update_aval) ) }