1313# ' @author Molly He (hey59) \email{[email protected] }1414# '
1515# ' @inherit argument_convention return
16+ # ' @inheritSection teal::example_module Reporting
1617# '
1718# ' @export
1819# '
@@ -104,10 +105,6 @@ ui_g_ae_sub <- function(id, ...) {
104105 plot_decorate_output(id = ns(NULL ))
105106 ),
106107 encoding = tags $ div(
107- # ## Reporter
108- teal.reporter :: add_card_button_ui(ns(" add_reporter" ), label = " Add Report Card" ),
109- tags $ br(), tags $ br(),
110- # ##
111108 tags $ label(" Encodings" , class = " text-primary" ),
112109 helpText(" Analysis data:" , tags $ code(" ADAE" )),
113110 teal.widgets :: optionalSelectInput(
@@ -175,14 +172,10 @@ ui_g_ae_sub <- function(id, ...) {
175172
176173srv_g_ae_sub <- function (id ,
177174 data ,
178- filter_panel_api ,
179- reporter ,
180175 dataname ,
181176 label ,
182177 plot_height ,
183178 plot_width ) {
184- with_reporter <- ! missing(reporter ) && inherits(reporter , " Reporter" )
185- with_filter <- ! missing(filter_panel_api ) && inherits(filter_panel_api , " FilterPanelAPI" )
186179 checkmate :: assert_class(data , " reactive" )
187180 checkmate :: assert_class(shiny :: isolate(data()), " teal_data" )
188181
@@ -317,8 +310,16 @@ srv_g_ae_sub <- function(id,
317310 output_q <- shiny :: debounce(
318311 millis = 200 ,
319312 r = reactive({
320- ANL <- data()[[dataname ]]
321- ADSL <- data()[[" ADSL" ]]
313+ obj <- data()
314+ teal.reporter :: teal_card(obj ) <-
315+ c(
316+ teal.reporter :: teal_card(" # AE by Subgroups" ),
317+ teal.reporter :: teal_card(obj ),
318+ teal.reporter :: teal_card(" ## Module's code" )
319+ )
320+
321+ ANL <- obj [[dataname ]]
322+ ADSL <- obj [[" ADSL" ]]
322323
323324 teal :: validate_has_data(ANL , min_nrow = 10 , msg = sprintf(" %s has not enough data" , dataname ))
324325
@@ -347,29 +348,33 @@ srv_g_ae_sub <- function(id,
347348 bquote(group_labels <- setNames(.(group_labels ), .(input $ groups )))
348349 }
349350
350- teal.code :: eval_code(data(), code = group_labels_call ) %> %
351- teal.code :: eval_code(code = " " ) %> %
352- teal.code :: eval_code(
353- code = as.expression(c(
354- bquote(
355- plot <- osprey :: g_ae_sub(
356- id = .(as.name(dataname ))$ USUBJID ,
357- arm = as.factor(.(as.name(dataname ))[[.(input $ arm_var )]]),
358- arm_sl = as.character(ADSL [[.(input $ arm_var )]]),
359- trt = .(input $ arm_trt ),
360- ref = .(input $ arm_ref ),
361- subgroups = .(as.name(dataname ))[.(input $ groups )],
362- subgroups_sl = ADSL [.(input $ groups )],
363- subgroups_levels = group_labels ,
364- conf_level = .(input $ conf_level ),
365- diff_ci_method = .(input $ ci ),
366- fontsize = .(font_size()),
367- arm_n = .(input $ arm_n ),
368- draw = TRUE
369- )
351+ q1 <- teal.code :: eval_code(obj , code = group_labels_call ) %> %
352+ teal.code :: eval_code(code = " " )
353+
354+ teal.reporter :: teal_card(q1 ) <- c(teal.reporter :: teal_card(q1 ), " ## Plot" )
355+
356+ teal.code :: eval_code(
357+ q1 ,
358+ code = as.expression(c(
359+ bquote(
360+ plot <- osprey :: g_ae_sub(
361+ id = .(as.name(dataname ))$ USUBJID ,
362+ arm = as.factor(.(as.name(dataname ))[[.(input $ arm_var )]]),
363+ arm_sl = as.character(ADSL [[.(input $ arm_var )]]),
364+ trt = .(input $ arm_trt ),
365+ ref = .(input $ arm_ref ),
366+ subgroups = .(as.name(dataname ))[.(input $ groups )],
367+ subgroups_sl = ADSL [.(input $ groups )],
368+ subgroups_levels = group_labels ,
369+ conf_level = .(input $ conf_level ),
370+ diff_ci_method = .(input $ ci ),
371+ fontsize = .(font_size()),
372+ arm_n = .(input $ arm_n ),
373+ draw = TRUE
370374 )
371- ))
372- )
375+ )
376+ ))
377+ )
373378 })
374379 )
375380
@@ -380,26 +385,6 @@ srv_g_ae_sub <- function(id,
380385 verbatim_content = reactive(teal.code :: get_code(output_q())),
381386 title = paste(" R code for" , label ),
382387 )
383-
384- # ## REPORTER
385- if (with_reporter ) {
386- card_fun <- function (comment , label ) {
387- card <- teal :: report_card_template(
388- title = " AE Subgroups" ,
389- label = label ,
390- with_filter = with_filter ,
391- filter_panel_api = filter_panel_api
392- )
393- card $ append_text(" Plot" , " header3" )
394- card $ append_plot(plot_r(), dim = pws $ dim())
395- if (! comment == " " ) {
396- card $ append_text(" Comment" , " header3" )
397- card $ append_text(comment )
398- }
399- card $ append_src(teal.code :: get_code(output_q()))
400- card
401- }
402- teal.reporter :: add_card_button_srv(" add_reporter" , reporter = reporter , card_fun = card_fun )
403- }
388+ set_chunk_dims(pws , output_q )
404389 })
405390}
0 commit comments