@@ -314,8 +314,7 @@ template_binary_outcome <- function(dataname,
314314
315315 y $ table <- substitute(
316316 expr = {
317- result <- rtables :: build_table(lyt = lyt , df = anl , alt_counts_df = parentname )
318- result
317+ table <- rtables :: build_table(lyt = lyt , df = anl , alt_counts_df = parentname )
319318 },
320319 env = list (parentname = as.name(parentname ))
321320 )
@@ -348,9 +347,18 @@ template_binary_outcome <- function(dataname,
348347# ' `"Not Evaluable (NE)"`, or `"Missing or unevaluable"`, 95% confidence interval will not be calculated.
349348# '
350349# ' * Reference arms are automatically combined if multiple arms selected as reference group.
350+ # ' @param decorators `r roxygen_decorators_param("tm_t_binary_outcome")`
351351# '
352352# ' @inherit module_arguments return seealso
353353# '
354+ # ' @section Decorating `tm_t_binary_outcome`:
355+ # '
356+ # ' This module generates the following objects, which can be modified in place using decorators:
357+ # ' - `table` (`TableTree` - output of `rtables::build_table`)
358+ # '
359+ # ' For additional details and examples of decorators, refer to the vignette
360+ # ' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
361+ # '
354362# ' @examplesShinylive
355363# ' library(teal.modules.clinical)
356364# ' interactive <- function() TRUE
@@ -464,7 +472,8 @@ tm_t_binary_outcome <- function(label,
464472 na_level = default_na_str(),
465473 pre_output = NULL ,
466474 post_output = NULL ,
467- basic_table_args = teal.widgets :: basic_table_args()) {
475+ basic_table_args = teal.widgets :: basic_table_args(),
476+ decorators = NULL ) {
468477 message(" Initializing tm_t_binary_outcome" )
469478 checkmate :: assert_string(label )
470479 checkmate :: assert_string(dataname )
@@ -504,6 +513,8 @@ tm_t_binary_outcome <- function(label,
504513 control $ strat $ method_ci , c(" wald" , " waldcc" , " cmh" , " ha" , " strat_newcombe" , " strat_newcombecc" )
505514 )
506515 checkmate :: assert_subset(control $ strat $ method_test , c(" cmh" ))
516+ decorators <- normalize_decorators(decorators )
517+ assert_decorators(decorators , " table" , null.ok = TRUE )
507518
508519 args <- as.list(environment())
509520
@@ -531,7 +542,8 @@ tm_t_binary_outcome <- function(label,
531542 control = control ,
532543 rsp_table = rsp_table ,
533544 na_level = na_level ,
534- basic_table_args = basic_table_args
545+ basic_table_args = basic_table_args ,
546+ decorators = decorators
535547 )
536548 ),
537549 datanames = teal.transform :: get_extract_datanames(data_extract_list )
@@ -678,6 +690,7 @@ ui_t_binary_outcome <- function(id, ...) {
678690 condition = paste0(" !input['" , ns(" compare_arms" ), " ']" ),
679691 checkboxInput(ns(" add_total" ), " Add All Patients column" , value = a $ add_total )
680692 ),
693+ ui_decorate_teal_data(ns(" decorator" ), decorators = select_decorators(a $ decorators , " table" )),
681694 teal.widgets :: panel_item(
682695 " Additional table settings" ,
683696 teal.widgets :: optionalSelectInput(
@@ -745,7 +758,8 @@ srv_t_binary_outcome <- function(id,
745758 default_responses ,
746759 rsp_table ,
747760 na_level ,
748- basic_table_args ) {
761+ basic_table_args ,
762+ decorators ) {
749763 with_reporter <- ! missing(reporter ) && inherits(reporter , " Reporter" )
750764 with_filter <- ! missing(filter_panel_api ) && inherits(filter_panel_api , " FilterPanelAPI" )
751765 checkmate :: assert_class(data , " reactive" )
@@ -995,8 +1009,16 @@ srv_t_binary_outcome <- function(id,
9951009 teal.code :: eval_code(qenv , as.expression(unlist(my_calls )))
9961010 })
9971011
1012+
1013+ decorated_all_q <- srv_decorate_teal_data(
1014+ id = " decorator" ,
1015+ data = table_q ,
1016+ decorators = select_decorators(decorators , " table" ),
1017+ expr = table
1018+ )
1019+
9981020 # Outputs to render.
999- table_r <- reactive(table_q ()[[" result " ]])
1021+ table_r <- reactive(decorated_all_q ()[[" table " ]])
10001022
10011023 teal.widgets :: table_with_settings_srv(
10021024 id = " table" ,
@@ -1007,7 +1029,7 @@ srv_t_binary_outcome <- function(id,
10071029 teal.widgets :: verbatim_popup_srv(
10081030 id = " rcode" ,
10091031 verbatim_content = reactive({
1010- teal.code :: get_code(table_q( ))
1032+ teal.code :: get_code(req(decorated_all_q() ))
10111033 }),
10121034 title = label
10131035 )
@@ -1027,7 +1049,7 @@ srv_t_binary_outcome <- function(id,
10271049 card $ append_text(" Comment" , " header3" )
10281050 card $ append_text(comment )
10291051 }
1030- card $ append_src(teal.code :: get_code(table_q( )))
1052+ card $ append_src(teal.code :: get_code(req(decorated_all_q() )))
10311053 card
10321054 }
10331055 teal.reporter :: simple_reporter_srv(" simple_reporter" , reporter = reporter , card_fun = card_fun )
0 commit comments