@@ -225,6 +225,8 @@ tm_a_regression <- function(label = "Regression Analysis",
225225 .var.name = " label_segment_threshold"
226226 )
227227 }
228+ decorators <- normalize_decorators(decorators )
229+ assert_decorators(decorators , " plot" , null.ok = TRUE )
228230 # End of assertions
229231
230232 # Make UI args
@@ -319,7 +321,7 @@ ui_a_regression <- function(id, ...) {
319321 label = " Outlier label"
320322 )
321323 ),
322- ui_transform_teal_data (ns(" decorate " ), transformators = args $ decorators ),
324+ ui_decorate_teal_data (ns(" decorator " ), decorators = select_decorators( args $ decorators , " plot " ) ),
323325 teal.widgets :: panel_group(
324326 teal.widgets :: panel_item(
325327 title = " Plot settings" ,
@@ -582,22 +584,15 @@ srv_a_regression <- function(id,
582584 shinyjs :: show(" size" )
583585 shinyjs :: show(" alpha" )
584586 plot <- substitute(
587+ expr = ggplot(fit $ model [, 2 : 1 ], aes_string(regressor , response )) +
588+ geom_point(size = size , alpha = alpha ) +
589+ stat_smooth(method = " lm" , formula = y ~ x , se = FALSE ),
585590 env = list (
586591 regressor = regression_var()$ regressor ,
587592 response = regression_var()$ response ,
588593 size = input $ size ,
589594 alpha = input $ alpha
590- ),
591- expr = ggplot(
592- fit $ model [, 2 : 1 ],
593- aes_string(regressor , response )
594- ) +
595- geom_point(size = size , alpha = alpha ) +
596- stat_smooth(
597- method = " lm" ,
598- formula = y ~ x ,
599- se = FALSE
600- )
595+ )
601596 )
602597 if (input $ show_outlier ) {
603598 plot <- substitute(
@@ -979,12 +974,16 @@ srv_a_regression <- function(id,
979974 )
980975 })
981976
982- decorated_output_q_no_print <- srv_transform_teal_data(" decorate" , data = output_q , transformators = decorators )
983- decorated_output_q <- reactive(within(decorated_output_q_no_print(), expr = print(plot )))
977+ decorated_output_q <- srv_decorate_teal_data(
978+ " decorator" ,
979+ data = output_q ,
980+ decorators = select_decorators(decorators , " plot" ),
981+ expr = print(plot )
982+ )
984983
985984 fitted <- reactive({
986985 req(output_q())
987- decorated_output_q_no_print ()[[" fit" ]]
986+ decorated_output_q ()[[" fit" ]]
988987 })
989988 plot_r <- reactive({
990989 req(output_q())
0 commit comments