Skip to content

Commit 6a36fe5

Browse files
committed
add req statement so that when srv_teal_transform_data returns NULL you see error from original teal_data
1 parent 3f506ea commit 6a36fe5

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

R/tm_outliers.R

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
#' Specifies variable(s) to be analyzed for outliers.
1212
#' @param categorical_var (`data_extract_spec` or `list` of multiple `data_extract_spec`) optional,
1313
#' specifies the categorical variable(s) to split the selected outlier variables on.
14-
#' @param table_decorator (`list` of `teal_transform_module`) optional,
14+
#' @param table_decorator (`list` of `teal_transform_module` or `NULL`) optional,
1515
#' decorator for the table.
16-
#' @param boxplot_decorator (`list` of `teal_transform_module`) optional,
16+
#' @param boxplot_decorator (`list` of `teal_transform_module` or `NULL`) optional,
1717
#' decorator for the box plot.
18-
#' @param violin_decorator (`list` of `teal_transform_module`) optional,
18+
#' @param violin_decorator (`list` of `teal_transform_module` or `NULL`) optional,
1919
#' decorator for the violin plot.
20-
#' @param density_decorator (`list` of `teal_transform_module`) optional,
20+
#' @param density_decorator (`list` of `teal_transform_module` or `NULL`) optional,
2121
#' decorator for the density plot.
22-
#' @param cum_dist_decorator (`list` of `teal_transform_module`) optional,
22+
#' @param cum_dist_decorator (`list` of `teal_transform_module` or `NULL`) optional,
2323
#' decorator for the cumulative distribution plot.
2424
#'
2525
#' @templateVar ggnames "Boxplot","Density Plot","Cumulative Distribution Plot"
@@ -149,11 +149,11 @@ tm_outliers <- function(label = "Outliers Module",
149149
plot_width = NULL,
150150
pre_output = NULL,
151151
post_output = NULL,
152-
table_decorator = teal_transform_module(),
153-
boxplot_decorator = teal_transform_module(),
154-
violin_decorator = teal_transform_module(),
155-
density_decorator = teal_transform_module(),
156-
cum_dist_decorator = teal_transform_module()) {
152+
table_decorator = NULL,
153+
boxplot_decorator = NULL,
154+
violin_decorator = NULL,
155+
density_decorator = NULL,
156+
cum_dist_decorator = NULL) {
157157
message("Initializing tm_outliers")
158158

159159
# Normalize the parameters
@@ -190,6 +190,13 @@ tm_outliers <- function(label = "Outliers Module",
190190

191191
checkmate::assert_multi_class(pre_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
192192
checkmate::assert_multi_class(post_output, c("shiny.tag", "shiny.tag.list", "html"), null.ok = TRUE)
193+
194+
checkmate::check_class(table_decorator, "teal_transform_module", null.ok = TRUE)
195+
checkmate::check_class(boxplot_decorator, "teal_transform_module", null.ok = TRUE)
196+
checkmate::check_class(violin_decorator, "teal_transform_module", null.ok = TRUE)
197+
checkmate::check_class(density_decorator, "teal_transform_module", null.ok = TRUE)
198+
checkmate::check_class(cum_dist_decorator, "teal_transform_module", null.ok = TRUE)
199+
193200
# End of assertions
194201

195202
# Make UI args
@@ -1073,14 +1080,17 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
10731080

10741081
boxplot_r <- reactive({
10751082
teal::validate_inputs(iv_r())
1083+
req(boxplot_q())
10761084
decorated_boxplot_q()[["plot"]]
10771085
})
10781086
density_plot_r <- reactive({
10791087
teal::validate_inputs(iv_r())
1088+
req(density_plot_q())
10801089
decorated_density_plot_q()[["plot"]]
10811090
})
10821091
cumulative_plot_r <- reactive({
10831092
teal::validate_inputs(iv_r())
1093+
req(cumulative_plot_q())
10841094
decorated_cumulative_plot_q()[["plot"]]
10851095
})
10861096

0 commit comments

Comments
 (0)