Skip to content

Commit 67755a0

Browse files
Warn and create an empty table (#930)
# Pull Request Fixes #924 Adds the section title even if no (informative) table can be generated. If the summary table cannot be generated a message or notification is displayed. The report can be now generated. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 84871a5 commit 67755a0

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

R/tm_outliers.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
#' vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl))
113113
#'
114114
#'
115-
#'
116115
#' app <- init(
117116
#' data = data,
118117
#' modules = modules(
@@ -649,8 +648,8 @@ srv_outliers <- function(id, data, outlier_var,
649648
)
650649
}
651650

651+
teal.reporter::teal_card(qenv) <- c(teal.reporter::teal_card(qenv), "## Summary Table")
652652
qenv <- if (length(categorical_var) > 0) {
653-
teal.reporter::teal_card(qenv) <- c(teal.reporter::teal_card(qenv), "## Summary Table")
654653
qenv <- teal.code::eval_code(
655654
qenv,
656655
substitute(
@@ -740,16 +739,19 @@ srv_outliers <- function(id, data, outlier_var,
740739
categorical_var_name = as.name(categorical_var)
741740
)
742741
)
743-
)
742+
) |> within({
743+
table <- rtables::df_to_tt(summary_data)
744+
table
745+
})
744746
} else {
745-
within(qenv, summary_data <- data.frame())
747+
msg <- "No categorical variable selected, summary table cannot be created."
748+
showNotification(msg,
749+
closeButton = FALSE, type = "warning",
750+
id = session$ns("no_summary_table")
751+
)
752+
within(qenv, cat(msg), msg = msg)
746753
}
747754

748-
# Generate decoratable object from data
749-
qenv <- within(qenv, {
750-
table <- rtables::df_to_tt(summary_data)
751-
table
752-
})
753755

754756
if (length(categorical_var) > 0 && nrow(qenv[["ANL_OUTLIER"]]) > 0) {
755757
shinyjs::show("order_by_outlier")

man/tm_outliers.Rd

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)