@@ -156,7 +156,7 @@ tm_a_regression <- function(label = "Regression Analysis",
156156 default_plot_type = 1 ,
157157 default_outlier_label = " USUBJID" ,
158158 label_segment_threshold = c(0.5 , 0 , 10 ),
159- decorators = list ( default = teal_transform_module()) ) {
159+ decorators = NULL ) {
160160 message(" Initializing tm_a_regression" )
161161
162162 # Normalize the parameters
@@ -210,7 +210,7 @@ tm_a_regression <- function(label = "Regression Analysis",
210210 checkmate :: assert_multi_class(post_output , c(" shiny.tag" , " shiny.tag.list" , " html" ), null.ok = TRUE )
211211 checkmate :: assert_choice(default_plot_type , seq.int(1L , length(plot_choices )))
212212 checkmate :: assert_string(default_outlier_label )
213- checkmate :: assert_list(decorators , " teal_transform_module" )
213+ checkmate :: assert_list(decorators , " teal_transform_module" , null.ok = TRUE )
214214
215215 if (length(label_segment_threshold ) == 1 ) {
216216 checkmate :: assert_numeric(label_segment_threshold , any.missing = FALSE , finite = TRUE )
@@ -1010,6 +1010,19 @@ srv_a_regression <- function(id,
10101010
10111011
10121012 output_q <- reactive({
1013+ teal :: validate_inputs(iv_r())
1014+ switch (input $ plot_type ,
1015+ " Response vs Regressor" = output_plot_0(),
1016+ " Residuals vs Fitted" = output_plot_1(),
1017+ " Normal Q-Q" = output_plot_2(),
1018+ " Scale-Location" = output_plot_3(),
1019+ " Cook's distance" = output_plot_4(),
1020+ " Residuals vs Leverage" = output_plot_5(),
1021+ " Cook's dist vs Leverage" = output_plot_6()
1022+ )
1023+ })
1024+
1025+ decorated_output_q <- reactive({
10131026 teal :: validate_inputs(iv_r())
10141027 switch (input $ plot_type ,
10151028 " Response vs Regressor" = decorated_output_0(),
@@ -1022,8 +1035,14 @@ srv_a_regression <- function(id,
10221035 )
10231036 })
10241037
1025- fitted <- reactive(output_q()[[" fit" ]])
1026- plot_r <- reactive(output_q()[[" plot" ]])
1038+ fitted <- reactive({
1039+ req(output_q())
1040+ decorated_output_q()[[" fit" ]]
1041+ })
1042+ plot_r <- reactive({
1043+ req(output_q())
1044+ decorated_output_q()[[" plot" ]]
1045+ })
10271046
10281047 # Insert the plot into a plot_with_settings module from teal.widgets
10291048 pws <- teal.widgets :: plot_with_settings_srv(
@@ -1043,7 +1062,7 @@ srv_a_regression <- function(id,
10431062
10441063 teal.widgets :: verbatim_popup_srv(
10451064 id = " rcode" ,
1046- verbatim_content = reactive(teal.code :: get_code(req(output_q ()))),
1065+ verbatim_content = reactive(teal.code :: get_code(req(decorated_output_q ()))),
10471066 title = " R code for the regression plot" ,
10481067 )
10491068
@@ -1062,7 +1081,7 @@ srv_a_regression <- function(id,
10621081 card $ append_text(" Comment" , " header3" )
10631082 card $ append_text(comment )
10641083 }
1065- card $ append_src(teal.code :: get_code(req(output_q ())))
1084+ card $ append_src(teal.code :: get_code(req(decorated_output_q ())))
10661085 card
10671086 }
10681087 teal.reporter :: simple_reporter_srv(" simple_reporter" , reporter = reporter , card_fun = card_fun )
0 commit comments