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 pct bug in tabulate_rsp_subgroups when risk difference column is added #1387

Merged
merged 5 commits into from
Jan 31, 2025
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Bug Fixes
* Fixed bug in `a_count_patients_with_flags()` preventing select custom label and indentation specification formats from being applied.
* Fixed bug in `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` preventing the `pct` option from having an effect when adding a risk difference column.

### Miscellaneous
* Removed internal function `ungroup_stats()` and replaced its usage with the `get_*_from_stats()` functions.
Expand Down
3 changes: 2 additions & 1 deletion R/response_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ tabulate_rsp_subgroups <- function(lyt,
x = as.list(.data[[arm_cols[1]]]),
y = as.list(.data[[arm_cols[2]]]),
N_x = .data[[arm_cols[3]]],
N_y = .data[[arm_cols[4]]]
N_y = .data[[arm_cols[4]]],
pct = riskdiff$pct
)
) %>%
dplyr::select(-dplyr::all_of(arm_cols))
Expand Down
3 changes: 2 additions & 1 deletion R/survival_duration_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ tabulate_survival_subgroups <- function(lyt,
x = as.list(.data[[arm_cols[1]]]),
y = as.list(.data[[arm_cols[2]]]),
N_x = .data[[arm_cols[3]]],
N_y = .data[[arm_cols[4]]]
N_y = .data[[arm_cols[4]]],
pct = riskdiff$pct
)
) %>%
dplyr::select(-dplyr::all_of(arm_cols))
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-response_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,23 @@ testthat::test_that("tabulate_rsp_subgroups riskdiff argument works as expected"

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)

# pct works
result2 <- basic_table() %>%
tabulate_rsp_subgroups(
df = df,
vars = c("n", "prop", "n_tot", "or", "ci", "pval"),
riskdiff = control_riskdiff(
arm_x = levels(df$prop$arm)[1],
arm_y = levels(df$prop$arm)[2],
pct = FALSE
)
)

testthat::expect_equal(
cell_values(result2)[[1]][[9]],
cell_values(result)[[1]][[9]] / 100
)
})

testthat::test_that("tabulate_rsp_subgroups pval statistic warning works as expected", {
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-survival_duration_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,17 @@ testthat::test_that("tabulate_survival_subgroups riskdiff argument works as expe

res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)

# pct works
result2 <- basic_table() %>%
tabulate_survival_subgroups(
df,
time_unit = adtte$AVALU[1],
riskdiff = control_riskdiff(pct = FALSE)
)

testthat::expect_equal(
cell_values(result2)[[1]][[8]],
cell_values(result)[[1]][[8]] / 100
)
})
Loading