Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix numeric_stats bug in tm_t_summary and tm_t_summary_by #771

Merged
merged 4 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Updated `tm_t_coxreg` module after refactoring `summarize_coxreg` in `tern` to fix indentation.
* Updated `tm_t_exposure` module to use new function `analyze_patients_exposure_in_cols` to fix table structure.

### Bug fixes
* Fixed bug in `tm_t_summary` and `tm_t_summary_by` preventing users from specifying the `numeric_stats` argument.

### Miscellaneous
* Package now uses `scda.2022` rather than `scda.2021` in SUGGESTS.
* Removed unused argument `param` from `tm_g_pp_vitals`.
Expand Down
9 changes: 3 additions & 6 deletions R/tm_t_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,16 @@ tm_t_summary <- function(label,
checkmate::assert_string(parentname)
checkmate::assert_string(na_level)
checkmate::assert_character(numeric_stats, min.len = 1)
checkmate::assert_subset(
numeric_stats,
c("n", "mean_sd", "mean_ci", "median", "median_ci", "quantiles", "range", "geom_mean")
)
useNA <- match.arg(useNA) # nolint
numeric_stats <- match.arg(numeric_stats)
denominator <- match.arg(denominator)
checkmate::assert_flag(drop_arm_levels)
checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(basic_table_args, "basic_table_args")
checkmate::assertFlag(add_total)

numeric_stats <- match.arg(numeric_stats, several.ok = TRUE)

args <- as.list(environment())

data_extract_list <- list(
Expand Down Expand Up @@ -366,7 +363,7 @@ ui_summary <- function(id, ...) {
"25% and 75%-ile" = "quantiles",
"Min - Max" = "range"
),
selected = c("n", "mean_sd", "median", "range")
selected = a$numeric_stats
),
shiny::radioButtons(
ns("denominator"),
Expand Down
7 changes: 5 additions & 2 deletions R/tm_t_summary_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,14 @@ tm_t_summary_by <- function(label,
checkmate::assert_flag(parallel_vars)
checkmate::assert_flag(row_groups)
checkmate::assert_flag(drop_arm_levels)
numeric_stats <- match.arg(numeric_stats)
checkmate::assert_character(numeric_stats, min.len = 1)
checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(basic_table_args, "basic_table_args")

numeric_stats_choices <- c("n", "mean_sd", "mean_ci", "geom_mean", "median", "median_ci", "quantiles", "range")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am agreeing a lot with #525 for this. It should be assigned dynamically from tern options. I am thinking how to do that. Also, notice that there seems to be a different number of methods here.

numeric_stats <- match.arg(numeric_stats, numeric_stats_choices, several.ok = TRUE)

args <- c(as.list(environment()))

data_extract_list <- list(
Expand Down Expand Up @@ -522,7 +525,7 @@ ui_summary_by <- function(id, ...) {
"25% and 75%-ile" = "quantiles",
"Min - Max" = "range"
),
selected = c("n", "mean_sd", "median", "range")
selected = a$numeric_stats
),
if (a$dataname == a$parentname) {
shinyjs::hidden(
Expand Down