@@ -69,9 +69,9 @@ template_a_gee <- function(output_table,
6969 if (output_table == " t_gee_cov" ) {
7070 substitute(
7171 expr = {
72- result_table <- tern.gee :: as.rtable(model_fit , type = " cov" )
73- subtitles(result_table ) <- st
74- main_footer(result_table ) <- mf
72+ table <- tern.gee :: as.rtable(model_fit , type = " cov" )
73+ subtitles(table ) <- st
74+ main_footer(table ) <- mf
7575 },
7676 env = list (
7777 st = basic_table_args $ subtitles ,
@@ -81,9 +81,9 @@ template_a_gee <- function(output_table,
8181 } else if (output_table == " t_gee_coef" ) {
8282 substitute(
8383 expr = {
84- result_table <- tern.gee :: as.rtable(data.frame (Coefficient = model_fit $ coefficients ))
85- subtitles(result_table ) <- st
86- main_footer(result_table ) <- mf
84+ table <- tern.gee :: as.rtable(data.frame (Coefficient = model_fit $ coefficients ))
85+ subtitles(table ) <- st
86+ main_footer(table ) <- mf
8787 },
8888 env = list (
8989 conf_level = conf_level ,
@@ -95,17 +95,16 @@ template_a_gee <- function(output_table,
9595 substitute(
9696 expr = {
9797 lsmeans_fit_model <- tern.gee :: lsmeans(model_fit , conf_level )
98- result_table <- rtables :: basic_table(show_colcounts = TRUE ) %> %
98+ table <- rtables :: basic_table(show_colcounts = TRUE ) %> %
9999 rtables :: split_cols_by(var = input_arm_var , ref_group = model_fit $ ref_level ) %> %
100100 tern.gee :: summarize_gee_logistic() %> %
101101 rtables :: build_table(
102102 df = lsmeans_fit_model ,
103103 alt_counts_df = dataname_lsmeans
104104 )
105105
106- subtitles(result_table ) <- st
107- main_footer(result_table ) <- mf
108- result_table
106+ subtitles(table ) <- st
107+ main_footer(table ) <- mf
109108 },
110109 env = list (
111110 dataname_lsmeans = as.name(dataname_lsmeans ),
@@ -135,6 +134,14 @@ template_a_gee <- function(output_table,
135134# '
136135# ' @inherit module_arguments return seealso
137136# '
137+ # ' @section Decorating Module:
138+ # '
139+ # ' This module generates the following objects, which can be modified in place using decorators:
140+ # ' - `table` (`ElementaryTable` - output of `rtables::build_table`)
141+ # '
142+ # ' For additional details and examples of decorators, refer to the vignette
143+ # ' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
144+ # '
138145# ' @examplesShinylive
139146# ' library(teal.modules.clinical)
140147# ' interactive <- function() TRUE
@@ -200,7 +207,8 @@ tm_a_gee <- function(label,
200207 conf_level = teal.transform :: choices_selected(c(0.95 , 0.9 , 0.8 ), 0.95 , keep_order = TRUE ),
201208 pre_output = NULL ,
202209 post_output = NULL ,
203- basic_table_args = teal.widgets :: basic_table_args()) {
210+ basic_table_args = teal.widgets :: basic_table_args(),
211+ decorators = NULL ) {
204212 message(" Initializing tm_a_gee (prototype)" )
205213
206214 cov_var <- teal.transform :: add_no_selected_choices(cov_var , multiple = TRUE )
@@ -218,6 +226,8 @@ tm_a_gee <- function(label,
218226 checkmate :: assert_class(pre_output , classes = " shiny.tag" , null.ok = TRUE )
219227 checkmate :: assert_class(post_output , classes = " shiny.tag" , null.ok = TRUE )
220228 checkmate :: assert_class(basic_table_args , " basic_table_args" )
229+ decorators <- normalize_decorators(decorators )
230+ assert_decorators(decorators , " table" , null.ok = TRUE )
221231
222232 args <- as.list(environment())
223233
@@ -243,7 +253,8 @@ tm_a_gee <- function(label,
243253 parentname = parentname ,
244254 arm_ref_comp = arm_ref_comp ,
245255 label = label ,
246- basic_table_args = basic_table_args
256+ basic_table_args = basic_table_args ,
257+ decorators = decorators
247258 )
248259 ),
249260 datanames = teal.transform :: get_extract_datanames(data_extract_list )
@@ -358,7 +369,8 @@ ui_gee <- function(id, ...) {
358369 " Coefficients" = " t_gee_coef"
359370 ),
360371 selected = " t_gee_lsmeans"
361- )
372+ ),
373+ ui_decorate_teal_data(ns(" decorator" ), decorators = select_decorators(a $ decorators , " table" ))
362374 ),
363375 forms = tagList(
364376 teal.widgets :: verbatim_popup_ui(ns(" rcode" ), button_label = " Show R code" )
@@ -385,7 +397,8 @@ srv_gee <- function(id,
385397 label ,
386398 plot_height ,
387399 plot_width ,
388- basic_table_args ) {
400+ basic_table_args ,
401+ decorators ) {
389402 with_reporter <- ! missing(reporter ) && inherits(reporter , " Reporter" )
390403 with_filter <- ! missing(filter_panel_api ) && inherits(filter_panel_api , " FilterPanelAPI" )
391404 checkmate :: assert_class(data , " reactive" )
@@ -546,19 +559,26 @@ srv_gee <- function(id,
546559 output_title
547560 })
548561
549- table_r <- reactive({
550- table_q()[[" result_table" ]]
551- })
562+ decorated_table_q <- srv_decorate_teal_data(
563+ id = " decorator" ,
564+ data = table_q ,
565+ decorators = select_decorators(decorators , " table" ),
566+ expr = table
567+ )
568+
569+ # Outputs to render.
570+ table_r <- reactive(decorated_table_q()[[" table" ]])
552571
553572 teal.widgets :: table_with_settings_srv(
554573 id = " table" ,
555574 table_r = table_r
556575 )
557576
558577 # Render R code
578+ source_code_r <- reactive(teal.code :: get_code(req(decorated_table_q())))
559579 teal.widgets :: verbatim_popup_srv(
560580 id = " rcode" ,
561- verbatim_content = reactive( teal.code :: get_code(table_q())) ,
581+ verbatim_content = source_code_r ,
562582 title = label
563583 )
564584
@@ -582,7 +602,7 @@ srv_gee <- function(id,
582602 card $ append_text(" Comment" , " header3" )
583603 card $ append_text(comment )
584604 }
585- card $ append_src(teal.code :: get_code(table_q() ))
605+ card $ append_src(source_code_r( ))
586606 card
587607 }
588608 teal.reporter :: simple_reporter_srv(" simple_reporter" , reporter = reporter , card_fun = card_fun )
0 commit comments