Skip to content

Commit bf87833

Browse files
committed
conditionalPanel for regression
1 parent 95e0fbf commit bf87833

File tree

1 file changed

+41
-14
lines changed

1 file changed

+41
-14
lines changed

R/tm_a_regression.R

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,41 @@ ui_a_regression <- function(id, decorate_objs, ...) {
295295
selected = args$plot_choices[args$default_plot_type]
296296
),
297297
div(
298-
# todo: conditionalPanel based on the values of input$plot_type (we don't want to show inputs for hidden plots)
299-
ui_transform_data(ns("d_0"), transforms = decorate_objs[[1]]),
300-
ui_transform_data(ns("d_1"), transforms = decorate_objs[[1]]),
301-
ui_transform_data(ns("d_2"), transforms = decorate_objs[[1]]),
302-
ui_transform_data(ns("d_3"), transforms = decorate_objs[[1]]),
303-
ui_transform_data(ns("d_4"), transforms = decorate_objs[[1]]),
304-
ui_transform_data(ns("d_5"), transforms = decorate_objs[[1]]),
305-
ui_transform_data(ns("d_6"), transforms = decorate_objs[[1]])
298+
conditionalPanel(
299+
condition = "input.plot_type == 'Response vs Regressor'",
300+
ns = ns,
301+
ui_transform_data(ns("d_0"), transforms = decorate_objs[[1]])
302+
),
303+
conditionalPanel(
304+
condition = "input.plot_type == 'Residuals vs Fitted'",
305+
ns = ns,
306+
ui_transform_data(ns("d_1"), transforms = decorate_objs[[1]])
307+
),
308+
conditionalPanel(
309+
condition = "input.plot_type == 'Normal Q-Q'",
310+
ns = ns,
311+
ui_transform_data(ns("d_2"), transforms = decorate_objs[[1]])
312+
),
313+
conditionalPanel(
314+
condition = "input.plot_type == 'Scale-Location'",
315+
ns = ns,
316+
ui_transform_data(ns("d_3"), transforms = decorate_objs[[1]])
317+
),
318+
conditionalPanel(
319+
condition = "input.plot_type == 'Cook\\'s distance'",
320+
ns = ns,
321+
ui_transform_data(ns("d_4"), transforms = decorate_objs[[1]])
322+
),
323+
conditionalPanel(
324+
condition = "input.plot_type == 'Residuals vs Leverage'",
325+
ns = ns,
326+
ui_transform_data(ns("d_5"), transforms = decorate_objs[[1]])
327+
),
328+
conditionalPanel(
329+
condition = "input.plot_type == 'Cook\\'s dist vs Leverage'",
330+
ns = ns,
331+
ui_transform_data(ns("d_6"), transforms = decorate_objs[[1]])
332+
),
306333
),
307334
checkboxInput(ns("show_outlier"), label = "Display outlier labels", value = TRUE),
308335
conditionalPanel(
@@ -991,13 +1018,13 @@ srv_a_regression <- function(id,
9911018
output_q <- reactive({
9921019
teal::validate_inputs(iv_r())
9931020
switch(input$plot_type,
994-
"Response vs Regressor" = output_plot_0(),
1021+
"Response vs Regressor" = decorated_output_0(),
9951022
"Residuals vs Fitted" = decorated_output_1(),
996-
"Normal Q-Q" = output_plot_2(),
997-
"Scale-Location" = output_plot_3(),
998-
"Cook's distance" = output_plot_4(),
999-
"Residuals vs Leverage" = output_plot_5(),
1000-
"Cook's dist vs Leverage" = output_plot_6()
1023+
"Normal Q-Q" = decorated_output_2(),
1024+
"Scale-Location" = decorated_output_3(),
1025+
"Cook's distance" = decorated_output_4(),
1026+
"Residuals vs Leverage" = decorated_output_5(),
1027+
"Cook's dist vs Leverage" = decorated_output_6()
10011028
)
10021029
})
10031030

0 commit comments

Comments
 (0)