diff --git a/R/string_ops.R b/R/string_ops.R index f6c3909b9..a5cb4c666 100644 --- a/R/string_ops.R +++ b/R/string_ops.R @@ -47,13 +47,13 @@ as_num.character <- function(str) { y <- lapply(y, as.numeric) y[unlist(lapply(y, length) == 0)] <- NA - return(y) + y } #' @export #' @rdname as_num as_num.numeric <- function(str) { - return(str) + str } #' @export @@ -61,12 +61,12 @@ as_num.numeric <- function(str) { as_num.factor <- function(str) { y <- as.character(str) y <- as_num(y) - return(y) + y } #' @export #' @rdname as_num as_num.logical <- function(str) { y <- as.numeric(str) - return(y) + y } diff --git a/R/tm_a_gee.R b/R/tm_a_gee.R index 0313dff61..c1d60c824 100644 --- a/R/tm_a_gee.R +++ b/R/tm_a_gee.R @@ -140,8 +140,21 @@ template_a_gee <- function(output_table, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`ElementaryTable` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_a_gee( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied to the `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -228,7 +241,6 @@ tm_a_gee <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_a_mmrm.R b/R/tm_a_mmrm.R index 3dbc5a7b6..790192df8 100644 --- a/R/tm_a_mmrm.R +++ b/R/tm_a_mmrm.R @@ -462,32 +462,34 @@ template_mmrm_plots <- function(fit_name, #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `lsmeans_plot` (`ggplot2`) -#' - `diagnostic_plot` (`TableTree`- output from `rtables::build_table`) +#' - `lsmeans_plot` (`ggplot`) +#' - `diagnostic_plot` (`ggplot`) #' - `lsmeans_table` (`TableTree`- output from `rtables::build_table`) -#' - `covariance_table` (`TableTree`- output from `rtables::build_table`) -#' - `fixed_effects_table` (`TableTree`- output from `rtables::build_table`) -#' - `diagnostic_table` (`TableTree`- output from `rtables::build_table`) +#' - `covariance_table` (`ElementaryTable`- output from `rtables::build_table`) +#' - `fixed_effects_table` (`ElementaryTable`- output from `rtables::build_table`) +#' - `diagnostic_table` (`ElementaryTable`- output from `rtables::build_table`) #' -#' Decorators can be applied to all outputs or only to specific objects using a -#' named list of `teal_transform_module` objects. -#' The `"default"` name is reserved for decorators that are applied to all outputs. +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. #' See code snippet below: #' #' ``` #' tm_a_mrmm( #' ..., # arguments for module #' decorators = list( -#' default = list(teal_transform_module(...)), # applied to all outputs -#' lsmeans_plot = list(teal_transform_module(...)) # applied only to `lsmeans_plot` output -#' diagnostic_plot = list(teal_transform_module(...)) # applied only to `diagnostic_plot` output -#' lsmeans_table = list(teal_transform_module(...)) # applied only to `lsmeans_table` output -#' covariance_table = list(teal_transform_module(...)) # applied only to `covariance_table` output -#' fixed_effects_table = list(teal_transform_module(...)) # applied only to `fixed_effects_table` output -#' diagnostic_table = list(teal_transform_module(...)) # applied only to `diagnostic_table` output +#' lsmeans_plot = teal_transform_module(...), # applied only to `lsmeans_plot` output +#' diagnostic_plot = teal_transform_module(...), # applied only to `diagnostic_plot` output +#' lsmeans_table = teal_transform_module(...), # applied only to `lsmeans_table` output +#' covariance_table = teal_transform_module(...), # applied only to `covariance_table` output +#' fixed_effects_table = teal_transform_module(...), # applied only to `fixed_effects_table` output +#' diagnostic_table = teal_transform_module(...) # applied only to `diagnostic_table` output #' ) #' ) #' ``` +#' +#' For additional details and examples of decorators, refer to the vignette +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. +#' #' @examplesShinylive #' library(teal.modules.clinical) #' interactive <- function() TRUE @@ -600,7 +602,6 @@ tm_a_mmrm <- function(label, checkmate::assert_list(ggplot2_args, types = "ggplot2_args") checkmate::assert_subset(names(ggplot2_args), c("default", plot_choices)) - decorators <- normalize_decorators(decorators) assert_decorators( decorators, c( diff --git a/R/tm_g_barchart_simple.R b/R/tm_g_barchart_simple.R index 6bfa5b655..d76f0bf66 100644 --- a/R/tm_g_barchart_simple.R +++ b/R/tm_g_barchart_simple.R @@ -19,10 +19,23 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_barchart_simple( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -182,7 +195,6 @@ tm_g_barchart_simple <- function(x = NULL, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, names = "plot") plot_options <- utils::modifyList( diff --git a/R/tm_g_ci.R b/R/tm_g_ci.R index 6e6f06df5..689627a3b 100644 --- a/R/tm_g_ci.R +++ b/R/tm_g_ci.R @@ -192,10 +192,23 @@ template_g_ci <- function(dataname, #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_ci( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -310,7 +323,6 @@ tm_g_ci <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_g_forest_rsp.R b/R/tm_g_forest_rsp.R index 31a0207c5..e2c4d6171 100644 --- a/R/tm_g_forest_rsp.R +++ b/R/tm_g_forest_rsp.R @@ -247,10 +247,23 @@ template_forest_rsp <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_forest_rsp( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -392,7 +405,6 @@ tm_g_forest_rsp <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_g_forest_tte.R b/R/tm_g_forest_tte.R index 152efa69a..8f19f0539 100644 --- a/R/tm_g_forest_tte.R +++ b/R/tm_g_forest_tte.R @@ -247,10 +247,23 @@ template_forest_tte <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_forest_tte( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -378,7 +391,6 @@ tm_g_forest_tte <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_g_ipp.R b/R/tm_g_ipp.R index 91fc5cafc..8517788e9 100644 --- a/R/tm_g_ipp.R +++ b/R/tm_g_ipp.R @@ -183,10 +183,23 @@ template_g_ipp <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_ipp( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' #' @examplesShinylive @@ -341,7 +354,6 @@ tm_g_ipp <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_g_km.R b/R/tm_g_km.R index 9cca4e806..4aea3c079 100644 --- a/R/tm_g_km.R +++ b/R/tm_g_km.R @@ -274,10 +274,23 @@ template_g_km <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_km( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' #' @examplesShinylive @@ -398,7 +411,6 @@ tm_g_km <- function(label, ) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_g_lineplot.R b/R/tm_g_lineplot.R index 14a53dc00..015c6915f 100644 --- a/R/tm_g_lineplot.R +++ b/R/tm_g_lineplot.R @@ -218,10 +218,23 @@ template_g_lineplot <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_lineplot( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -349,7 +362,6 @@ tm_g_lineplot <- function(label, checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_g_pp_adverse_events.R b/R/tm_g_pp_adverse_events.R index e60f6dc31..260bed56b 100644 --- a/R/tm_g_pp_adverse_events.R +++ b/R/tm_g_pp_adverse_events.R @@ -184,30 +184,28 @@ template_adverse_events <- function(dataname = "ANL", #' #' @inherit module_arguments return #' -#' @section Decorating Modules: +#' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators:: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) #' - `table` (`listing_df` - output of `rlistings::as_listing`) #' -#' Decorators can be applied to all outputs or only to specific objects using a -#' named list of `teal_transform_module` objects. -#' The `"default"` name is reserved for decorators that are applied to all outputs. +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. #' See code snippet below: #' #' ``` #' tm_g_pp_adverse_events( #' ..., # arguments for module #' decorators = list( -#' default = list(teal_transform_module(...)), # applied to all outputs -#' plot = list(teal_transform_module(...)), # applied only to `plot` output -#' table = list(teal_transform_module(...)) # applied only to `table` output +#' plot = teal_transform_module(...), # applied only to `plot` output +#' table = teal_transform_module(...) # applied only to `table` output #' ) #' ) #' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -314,7 +312,6 @@ tm_g_pp_adverse_events <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, names = c("plot", "table")) args <- as.list(environment()) diff --git a/R/tm_g_pp_patient_timeline.R b/R/tm_g_pp_patient_timeline.R index 350344609..8739e198f 100644 --- a/R/tm_g_pp_patient_timeline.R +++ b/R/tm_g_pp_patient_timeline.R @@ -351,10 +351,23 @@ template_patient_timeline <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_pp_patient_timeline( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' #' @examplesShinylive @@ -499,7 +512,6 @@ tm_g_pp_patient_timeline <- function(label, plot_width[1], lower = plot_width[2], upper = plot_width[3], null.ok = TRUE, .var.name = "plot_width" ) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") xor_error_string <- function(x, y) { diff --git a/R/tm_g_pp_therapy.R b/R/tm_g_pp_therapy.R index c51de8ccd..0bedc7de7 100644 --- a/R/tm_g_pp_therapy.R +++ b/R/tm_g_pp_therapy.R @@ -248,27 +248,25 @@ template_therapy <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators:: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) #' - `table` (`listing_df` - output of `rlistings::as_listing`) #' -#' Decorators can be applied to all outputs or only to specific objects using a -#' named list of `teal_transform_module` objects. -#' The `"default"` name is reserved for decorators that are applied to all outputs. +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. #' See code snippet below: #' #' ``` #' tm_g_pp_therapy( #' ..., # arguments for module #' decorators = list( -#' default = list(teal_transform_module(...)), # applied to all outputs -#' plot = list(teal_transform_module(...)), # applied only to `plot` output -#' table = list(teal_transform_module(...)) # applied only to `table` output +#' plot = teal_transform_module(...), # applied only to `plot` output +#' table = teal_transform_module(...) # applied only to `table` output #' ) #' ) #' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -400,7 +398,6 @@ tm_g_pp_therapy <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(ggplot2_args, "ggplot2_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, names = c("plot", "table")) args <- as.list(environment()) diff --git a/R/tm_g_pp_vitals.R b/R/tm_g_pp_vitals.R index 02f918272..3e8590b21 100644 --- a/R/tm_g_pp_vitals.R +++ b/R/tm_g_pp_vitals.R @@ -213,10 +213,23 @@ template_vitals <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `plot` (`ggplot`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_g_pp_vitals( +#' ..., # arguments for module +#' decorators = list( +#' plot = teal_transform_module(...) # applied only to `plot` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' #' @examplesShinylive @@ -316,7 +329,6 @@ tm_g_pp_vitals <- function(label, checkmate::assert_multi_class(paramcd, c("choices_selected", "data_extract_spec"), null.ok = TRUE) checkmate::assert_multi_class(aval_var, c("choices_selected", "data_extract_spec"), null.ok = TRUE) checkmate::assert_multi_class(xaxis, c("choices_selected", "data_extract_spec"), null.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "plot") args <- as.list(environment()) diff --git a/R/tm_t_abnormality.R b/R/tm_t_abnormality.R index d8b0debd5..ede18ca74 100644 --- a/R/tm_t_abnormality.R +++ b/R/tm_t_abnormality.R @@ -240,10 +240,23 @@ template_abnormality <- function(parentname, #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `table` (`ElementaryTable` - output of `rtables::build_table`) +#' - `table` (`TableTree` - output of `rtables::build_table`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_abnormality( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @note Patients with the same abnormality at baseline as on the treatment visit can be #' excluded in accordance with GDSR specifications by using `exclude_base_abn`. @@ -361,7 +374,6 @@ tm_t_abnormality <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") data_extract_list <- list( diff --git a/R/tm_t_abnormality_by_worst_grade.R b/R/tm_t_abnormality_by_worst_grade.R index 2aa6a2805..2b5dead77 100644 --- a/R/tm_t_abnormality_by_worst_grade.R +++ b/R/tm_t_abnormality_by_worst_grade.R @@ -252,10 +252,23 @@ template_abnormality_by_worst_grade <- function(parentname, # nolint: object_len #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `table` (`ElementaryTable` - output of `rtables::build_table`) +#' - `table` (`TableTree` - output of `rtables::build_table`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_abnormality_by_worst_grade( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @export #' @@ -365,7 +378,6 @@ tm_t_abnormality_by_worst_grade <- function(label, # nolint: object_length. checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") data_extract_list <- list( diff --git a/R/tm_t_ancova.R b/R/tm_t_ancova.R index a9051599b..ef1260076 100644 --- a/R/tm_t_ancova.R +++ b/R/tm_t_ancova.R @@ -428,10 +428,23 @@ template_ancova <- function(dataname = "ANL", #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `table` (`ElementaryTable` - output of `rtables::build_table`) +#' - `table` (`TableTree` - output of `rtables::build_table`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_ancova( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @details #' When a single endpoint is selected, both unadjusted and adjusted comparison are provided. This modules @@ -544,7 +557,6 @@ tm_t_ancova <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- c(as.list(environment())) diff --git a/R/tm_t_binary_outcome.R b/R/tm_t_binary_outcome.R index 6b8fea079..76a9ac217 100644 --- a/R/tm_t_binary_outcome.R +++ b/R/tm_t_binary_outcome.R @@ -356,8 +356,21 @@ template_binary_outcome <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_binary_outcome( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -514,7 +527,6 @@ tm_t_binary_outcome <- function(label, control$strat$method_ci, c("wald", "waldcc", "cmh", "ha", "strat_newcombe", "strat_newcombecc") ) checkmate::assert_subset(control$strat$method_test, c("cmh")) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_coxreg.R b/R/tm_t_coxreg.R index d42f1f3b8..88ea803bb 100644 --- a/R/tm_t_coxreg.R +++ b/R/tm_t_coxreg.R @@ -366,8 +366,21 @@ template_coxreg_m <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` as created from `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_coxreg( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -546,7 +559,6 @@ tm_t_coxreg <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_events.R b/R/tm_t_events.R index 2283a6f71..faa0912a8 100644 --- a/R/tm_t_events.R +++ b/R/tm_t_events.R @@ -467,8 +467,21 @@ template_events <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` as created from `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_events( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -556,7 +569,6 @@ tm_t_events <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_events_by_grade.R b/R/tm_t_events_by_grade.R index d801f6f3a..1a4e7af40 100644 --- a/R/tm_t_events_by_grade.R +++ b/R/tm_t_events_by_grade.R @@ -786,8 +786,21 @@ template_events_col_by_grade <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` as created from `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_events_by_grade( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @export #' @@ -883,7 +896,6 @@ tm_t_events_by_grade <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_events_patyear.R b/R/tm_t_events_patyear.R index 620b0f8da..caee5c710 100644 --- a/R/tm_t_events_patyear.R +++ b/R/tm_t_events_patyear.R @@ -196,10 +196,23 @@ template_events_patyear <- function(dataname, #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `table` (`TableTree` as created from `rtables::build_table`) +#' - `table` (`ElementaryTable` as created from `rtables::build_table`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_events_patyear( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' #' @examples @@ -339,7 +352,6 @@ tm_t_events_patyear <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- c(as.list(environment())) diff --git a/R/tm_t_events_summary.R b/R/tm_t_events_summary.R index 04c71c396..c15409285 100644 --- a/R/tm_t_events_summary.R +++ b/R/tm_t_events_summary.R @@ -528,8 +528,21 @@ template_events_summary <- function(anl_name, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` as created from `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_events_summary( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -672,7 +685,6 @@ tm_t_events_summary <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- c(as.list(environment())) diff --git a/R/tm_t_exposure.R b/R/tm_t_exposure.R index 35b28ccb5..3e3451667 100644 --- a/R/tm_t_exposure.R +++ b/R/tm_t_exposure.R @@ -227,13 +227,26 @@ template_exposure <- function(parentname, #' #' @inherit module_arguments return seealso #' -#' @section Decorating Modules: +#' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `table` (`TableTree` as created from `rtables::build_table`) +#' - `table` (`ElementaryTable` as created from `rtables::build_table`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_exposure( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -354,7 +367,6 @@ tm_t_exposure <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") data_extract_list <- list( diff --git a/R/tm_t_logistic.R b/R/tm_t_logistic.R index d7ac1a23f..89a2c04ee 100644 --- a/R/tm_t_logistic.R +++ b/R/tm_t_logistic.R @@ -225,10 +225,23 @@ template_logistic <- function(dataname, #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `table` (`ElementaryTable` - output of `rtables::build_table`) +#' - `table` (`TableTree` - output of `rtables::build_table`) +#' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_logistic( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` #' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -321,7 +334,6 @@ tm_t_logistic <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_mult_events.R b/R/tm_t_mult_events.R index 65aad7b65..b1dfc970c 100644 --- a/R/tm_t_mult_events.R +++ b/R/tm_t_mult_events.R @@ -290,8 +290,21 @@ template_mult_events <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_mult_events( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -376,7 +389,6 @@ tm_t_mult_events <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_pp_basic_info.R b/R/tm_t_pp_basic_info.R index 3d8ff9cb9..0fefb0b69 100644 --- a/R/tm_t_pp_basic_info.R +++ b/R/tm_t_pp_basic_info.R @@ -70,8 +70,21 @@ template_basic_info <- function(dataname = "ANL", #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`listing_df` - output of `rlistings::as_listing`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_pp_basic_info( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -121,7 +134,6 @@ tm_t_pp_basic_info <- function(label, checkmate::assert_class(vars, "choices_selected", null.ok = TRUE) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_pp_laboratory.R b/R/tm_t_pp_laboratory.R index 8ff251a27..e09b6715b 100644 --- a/R/tm_t_pp_laboratory.R +++ b/R/tm_t_pp_laboratory.R @@ -159,8 +159,21 @@ template_laboratory <- function(dataname = "ANL", #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`listing_df` - output of `rlistings::as_listing`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_pp_laboratory( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -268,7 +281,6 @@ tm_t_pp_laboratory <- function(label, checkmate::assert_class(anrind, "choices_selected", null.ok = TRUE) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_pp_medical_history.R b/R/tm_t_pp_medical_history.R index 243e25273..5cc8ea31c 100644 --- a/R/tm_t_pp_medical_history.R +++ b/R/tm_t_pp_medical_history.R @@ -92,8 +92,21 @@ template_medical_history <- function(dataname = "ANL", #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_pp_medical_history( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -160,7 +173,6 @@ tm_t_pp_medical_history <- function(label, checkmate::assert_class(mhdistat, "choices_selected", null.ok = TRUE) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_pp_prior_medication.R b/R/tm_t_pp_prior_medication.R index b7bcb573e..f983943e2 100644 --- a/R/tm_t_pp_prior_medication.R +++ b/R/tm_t_pp_prior_medication.R @@ -74,8 +74,21 @@ template_prior_medication <- function(dataname = "ANL", #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`listing_df` - output of `rlistings::as_listing`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_pp_prior_medication( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -153,7 +166,6 @@ tm_t_pp_prior_medication <- function(label, checkmate::assert_class(cmstdy, "choices_selected", null.ok = TRUE) checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_shift_by_arm.R b/R/tm_t_shift_by_arm.R index 92119e942..7f0bd6ef2 100644 --- a/R/tm_t_shift_by_arm.R +++ b/R/tm_t_shift_by_arm.R @@ -196,8 +196,21 @@ template_shift_by_arm <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_shift_by_arm( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -307,7 +320,6 @@ tm_t_shift_by_arm <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_shift_by_arm_by_worst.R b/R/tm_t_shift_by_arm_by_worst.R index ea2be9bcc..4f4222848 100644 --- a/R/tm_t_shift_by_arm_by_worst.R +++ b/R/tm_t_shift_by_arm_by_worst.R @@ -202,8 +202,21 @@ template_shift_by_arm_by_worst <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_shift_by_arm_by_worst( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -317,7 +330,6 @@ tm_t_shift_by_arm_by_worst <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_shift_by_grade.R b/R/tm_t_shift_by_grade.R index b8512dfcb..e371f1678 100644 --- a/R/tm_t_shift_by_grade.R +++ b/R/tm_t_shift_by_grade.R @@ -477,8 +477,21 @@ template_shift_by_grade <- function(parentname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_shift_by_grade( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -603,7 +616,6 @@ tm_t_shift_by_grade <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_smq.R b/R/tm_t_smq.R index 9b4a9aeca..eff35a37a 100644 --- a/R/tm_t_smq.R +++ b/R/tm_t_smq.R @@ -321,8 +321,21 @@ template_smq <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_smq( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -418,7 +431,6 @@ tm_t_smq <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/tm_t_summary.R b/R/tm_t_summary.R index b92cfdaa6..39a0c62da 100644 --- a/R/tm_t_summary.R +++ b/R/tm_t_summary.R @@ -228,8 +228,21 @@ template_summary <- function(dataname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_summary( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -307,7 +320,6 @@ tm_t_summary <- function(label, checkmate::assert_flag(add_total) checkmate::assert_flag(show_arm_var_labels) checkmate::assert_string(total_label) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") useNA <- match.arg(useNA) # nolint: object_name. diff --git a/R/tm_t_summary_by.R b/R/tm_t_summary_by.R index ba17f3098..00b07bd24 100644 --- a/R/tm_t_summary_by.R +++ b/R/tm_t_summary_by.R @@ -325,8 +325,21 @@ template_summary_by <- function(parentname, #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_summary_by( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @examplesShinylive #' library(teal.modules.clinical) @@ -433,7 +446,6 @@ tm_t_summary_by <- function(label, numeric_stats_choices <- c("n", "mean_sd", "mean_ci", "geom_mean", "median", "median_ci", "quantiles", "range") numeric_stats <- match.arg(numeric_stats, numeric_stats_choices, several.ok = TRUE) - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- c(as.list(environment())) diff --git a/R/tm_t_tte.R b/R/tm_t_tte.R index 3c1944257..3806f9ae4 100644 --- a/R/tm_t_tte.R +++ b/R/tm_t_tte.R @@ -393,8 +393,21 @@ template_tte <- function(dataname = "ANL", #' This module generates the following objects, which can be modified in place using decorators: #' - `table` (`TableTree` - output of `rtables::build_table`) #' +#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects. +#' The name of this list corresponds to the name of the output to which the decorator is applied. +#' See code snippet below: +#' +#' ``` +#' tm_t_tte( +#' ..., # arguments for module +#' decorators = list( +#' table = teal_transform_module(...) # applied only to `table` output +#' ) +#' ) +#' ``` +#' #' For additional details and examples of decorators, refer to the vignette -#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation. +#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation. #' #' @details #' * The core functionality of this module is based on [tern::coxph_pairwise()], [tern::surv_timepoint()], @@ -523,7 +536,6 @@ tm_t_tte <- function(label, checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE) checkmate::assert_class(basic_table_args, "basic_table_args") - decorators <- normalize_decorators(decorators) assert_decorators(decorators, "table") args <- as.list(environment()) diff --git a/R/utils.R b/R/utils.R index 84cf3fb96..debfd65b2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -71,7 +71,7 @@ get_var_labels <- function(datasets, dataname, vars) { ) labels <- datasets$get_varlabels(dataname, vars) labels <- vapply(vars, function(x) ifelse(is.na(labels[[x]]), x, labels[[x]]), character(1)) - return(labels) + labels } #' Expression Deparsing @@ -450,7 +450,7 @@ split_choices <- function(x) { split_x$selected <- split_interactions(x$selected) } - return(split_x) + split_x } #' Extracts html id for `data_extract_ui` @@ -1009,25 +1009,18 @@ check_decorators <- function(x, names = NULL) { # nolint: object_name. check_message <- checkmate::check_list(x, names = "named") if (!is.null(names)) { - check_message <- if (isTRUE(check_message)) { - out_message <- checkmate::check_names(names(x), subset.of = c("default", names)) + if (isTRUE(check_message)) { if (length(names(x)) != length(unique(names(x)))) { - unique_message <- "Non-unique names in decorators" - if (isTRUE(out_message)) { - out_message <- unique_message - } else { - out_message <- paste0(out_message, ". Also, ", tolower(unique_message)) - } - } - - # see https://github.com/insightsengineering/teal.logger/issues/101 - if (isTRUE(out_message)) { - out_message - } else { - gsub("\\{", "(", gsub("\\}", ")", out_message)) + check_message <- sprintf( + "The `decorators` must contain unique names from these names: %s.", + paste(names, collapse = ", ") + ) } } else { - check_message + check_message <- sprintf( + "The `decorators` must be a named list from these names: %s.", + paste(names, collapse = ", ") + ) } } @@ -1037,8 +1030,8 @@ check_decorators <- function(x, names = NULL) { # nolint: object_name. valid_elements <- vapply( x, - checkmate::test_list, - types = "teal_transform_module", + checkmate::test_class, + classes = "teal_transform_module", FUN.VALUE = logical(1L) ) @@ -1046,48 +1039,25 @@ check_decorators <- function(x, names = NULL) { # nolint: object_name. return(TRUE) } - "May only contain the type 'teal_transform_module' or a named list of 'teal_transform_module'." + "Make sure that the named list contains 'teal_transform_module' objects created using `teal_transform_module()`." } - #' Internal assertion on decorators #' @noRd assert_decorators <- checkmate::makeAssertionFunction(check_decorators) #' Subset decorators based on the scope #' -#' `default` is a protected decorator name that is always included in the output, -#' if it exists -#' #' @param scope (`character`) a character vector of decorator names to include. #' @param decorators (named `list`) of list decorators to subset. #' -#' @return A flat list with all decorators to include. +#' @return Subsetted list with all decorators to include. #' It can be an empty list if none of the scope exists in `decorators` argument. #' @keywords internal select_decorators <- function(decorators, scope) { checkmate::assert_character(scope, null.ok = TRUE) - scope <- intersect(union("default", scope), names(decorators)) - c(list(), unlist(decorators[scope], recursive = FALSE)) -} - -#' Convert flat list of `teal_transform_module` to named lists -#' -#' @param decorators (list of `teal_transform_module`) to normalize. -#' @return A named list of lists with `teal_transform_module` objects. -#' @keywords internal -normalize_decorators <- function(decorators) { - if (checkmate::test_list(decorators, "teal_transform_module")) { - decorators_names <- names(decorators)[!names(decorators) %in% ""] - # Above is equivalent to decorators_names <- setdiff(names(decorators), "") - # but can return non-unique values. Non-unique values are checked in assert_decorators. - if (length(decorators_names) == 0) { - list(default = decorators) - } else if (length(decorators_names) == length(decorators)) { - lapply(decorators, list) - } else { - stop("All decorators should either be named or unnamed.") - } + if (scope %in% names(decorators)) { + decorators[scope] } else { - decorators + list() } } diff --git a/man/normalize_decorators.Rd b/man/normalize_decorators.Rd deleted file mode 100644 index 257342765..000000000 --- a/man/normalize_decorators.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{normalize_decorators} -\alias{normalize_decorators} -\title{Convert flat list of \code{teal_transform_module} to named lists} -\usage{ -normalize_decorators(decorators) -} -\arguments{ -\item{decorators}{(list of \code{teal_transform_module}) to normalize.} -} -\value{ -A named list of lists with \code{teal_transform_module} objects. -} -\description{ -Convert flat list of \code{teal_transform_module} to named lists -} -\keyword{internal} diff --git a/man/select_decorators.Rd b/man/select_decorators.Rd index 2c7403dca..bf004d541 100644 --- a/man/select_decorators.Rd +++ b/man/select_decorators.Rd @@ -12,11 +12,10 @@ select_decorators(decorators, scope) \item{scope}{(\code{character}) a character vector of decorator names to include.} } \value{ -A flat list with all decorators to include. +Subsetted list with all decorators to include. It can be an empty list if none of the scope exists in \code{decorators} argument. } \description{ -\code{default} is a protected decorator name that is always included in the output, -if it exists +Subset decorators based on the scope } \keyword{internal} diff --git a/man/tm_a_gee.Rd b/man/tm_a_gee.Rd index 1a5f619fe..6e7f522c9 100644 --- a/man/tm_a_gee.Rd +++ b/man/tm_a_gee.Rd @@ -98,8 +98,20 @@ This module generates the following objects, which can be modified in place usin \item \code{table} (\code{ElementaryTable} - output of \code{rtables::build_table}) } +A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. +The name of this list corresponds to the name of the output to which the decorator is applied. +See code snippet below: + +\if{html}{\out{