Skip to content

Commit 9ae70c4

Browse files
committed
simplify usage for regression
1 parent 9ef1032 commit 9ae70c4

File tree

1 file changed

+4
-59
lines changed

1 file changed

+4
-59
lines changed

R/tm_a_regression.R

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -288,43 +288,6 @@ ui_a_regression <- function(id, ...) {
288288
choices = args$plot_choices,
289289
selected = args$plot_choices[args$default_plot_type]
290290
),
291-
div(
292-
conditionalPanel(
293-
condition = "input.plot_type == 'Response vs Regressor'",
294-
ns = ns,
295-
ui_transform_teal_data(ns("d_0"), transformators = args$decorators)
296-
),
297-
conditionalPanel(
298-
condition = "input.plot_type == 'Residuals vs Fitted'",
299-
ns = ns,
300-
ui_transform_teal_data(ns("d_1"), transformators = args$decorators)
301-
),
302-
conditionalPanel(
303-
condition = "input.plot_type == 'Normal Q-Q'",
304-
ns = ns,
305-
ui_transform_teal_data(ns("d_2"), transformators = args$decorators)
306-
),
307-
conditionalPanel(
308-
condition = "input.plot_type == 'Scale-Location'",
309-
ns = ns,
310-
ui_transform_teal_data(ns("d_3"), transformators = args$decorators)
311-
),
312-
conditionalPanel(
313-
condition = "input.plot_type == 'Cook\\'s distance'",
314-
ns = ns,
315-
ui_transform_teal_data(ns("d_4"), transformators = args$decorators)
316-
),
317-
conditionalPanel(
318-
condition = "input.plot_type == 'Residuals vs Leverage'",
319-
ns = ns,
320-
ui_transform_teal_data(ns("d_5"), transformators = args$decorators)
321-
),
322-
conditionalPanel(
323-
condition = "input.plot_type == 'Cook\\'s dist vs Leverage'",
324-
ns = ns,
325-
ui_transform_teal_data(ns("d_6"), transformators = args$decorators)
326-
),
327-
),
328291
checkboxInput(ns("show_outlier"), label = "Display outlier labels", value = TRUE),
329292
conditionalPanel(
330293
condition = "input['show_outlier']",
@@ -354,6 +317,7 @@ ui_a_regression <- function(id, ...) {
354317
label = "Outlier label"
355318
)
356319
),
320+
ui_transform_teal_data(ns("decorate"), transformators = args$decorators),
357321
teal.widgets::panel_group(
358322
teal.widgets::panel_item(
359323
title = "Plot settings",
@@ -1000,15 +964,6 @@ srv_a_regression <- function(id,
1000964
)
1001965
})
1002966

1003-
decorated_output_0 <- srv_transform_teal_data(id = "d_0", data = output_plot_0, transformators = decorators)
1004-
decorated_output_1 <- srv_transform_teal_data(id = "d_1", data = output_plot_1, transformators = decorators)
1005-
decorated_output_2 <- srv_transform_teal_data(id = "d_2", data = output_plot_2, transformators = decorators)
1006-
decorated_output_3 <- srv_transform_teal_data(id = "d_3", data = output_plot_3, transformators = decorators)
1007-
decorated_output_4 <- srv_transform_teal_data(id = "d_4", data = output_plot_4, transformators = decorators)
1008-
decorated_output_5 <- srv_transform_teal_data(id = "d_5", data = output_plot_5, transformators = decorators)
1009-
decorated_output_6 <- srv_transform_teal_data(id = "d_6", data = output_plot_6, transformators = decorators)
1010-
1011-
1012967
output_q <- reactive({
1013968
teal::validate_inputs(iv_r())
1014969
switch(input$plot_type,
@@ -1022,22 +977,12 @@ srv_a_regression <- function(id,
1022977
)
1023978
})
1024979

1025-
decorated_output_q <- reactive({
1026-
teal::validate_inputs(iv_r())
1027-
switch(input$plot_type,
1028-
"Response vs Regressor" = decorated_output_0(),
1029-
"Residuals vs Fitted" = decorated_output_1(),
1030-
"Normal Q-Q" = decorated_output_2(),
1031-
"Scale-Location" = decorated_output_3(),
1032-
"Cook's distance" = decorated_output_4(),
1033-
"Residuals vs Leverage" = decorated_output_5(),
1034-
"Cook's dist vs Leverage" = decorated_output_6()
1035-
)
1036-
})
980+
decorated_output_q_no_print <- srv_transform_teal_data("decorate", data = output_q, transformators = decorators)
981+
decorated_output_q <- reactive(within(decorated_output_q_no_print(), expr = print(plot)))
1037982

1038983
fitted <- reactive({
1039984
req(output_q())
1040-
decorated_output_q()[["fit"]]
985+
decorated_output_q_no_print()[["fit"]]
1041986
})
1042987
plot_r <- reactive({
1043988
req(output_q())

0 commit comments

Comments
 (0)