Skip to content

Commit

Permalink
Merge branch 'main' into 1294_n_rate_est_incidence@main
Browse files Browse the repository at this point in the history
Signed-off-by: Emily de la Rua <[email protected]>
  • Loading branch information
edelarua authored Sep 5, 2024
2 parents 97e1ca4 + 716a290 commit 7db0da2
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tern
Title: Create Common TLGs Used in Clinical Trials
Version: 0.9.5.9017
Date: 2024-09-04
Version: 0.9.5.9018
Date: 2024-09-05
Authors@R: c(
person("Joe", "Zhu", , "[email protected]", role = c("aut", "cre")),
person("Daniel", "Sabanés Bové", , "[email protected]", role = "aut"),
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# tern 0.9.5.9017
# tern 0.9.5.9018
### Enhancements
* Added `errorbar_width` and `linetype` parameters to `g_lineplot`.
* Reworking of `summarize_glm_count()` documentation and all its associated functions to better describe the results and the functions' purpose.
* Added the `.formats` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to specify formats.
* Added the `riskdiff` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to add a risk difference table column, and function `control_riskdiff` to specify settings for the risk difference column.
* Added warning to `tabulate_rsp_subgroups` when `pval` statistic is selected but `df` has not been correctly generated to add p-values to the output table.
* Added `n_rate` statistic as a non-default option to `estimate_incidence_rate` which returns both number of events observed and estimated incidence rate.

### Bug Fixes
Expand All @@ -16,7 +17,6 @@
* Fixed bug in `decorate_grob` that did not handle well empty strings or `NULL` values for title and footers.
* Fixed bug in `g_km` that caused an error when multiple records in the data had estimates at max time.


### Miscellaneous
* Began deprecation of the confusing functions `summary_formats` and `summary_labels`.

Expand Down
2 changes: 1 addition & 1 deletion R/argument_convention.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#' for more information.
#' @param lyt (`PreDataTableLayouts`)\cr layout that analyses will be added to.
#' @param method (`string` or `NULL`)\cr specifies the test used to calculate the p-value for the difference between
#' two proportions. For options, see [s_test_proportion_diff()]. Default is `NULL` so no test is performed.
#' two proportions. For options, see [test_proportion_diff()]. Default is `NULL` so no test is performed.
#' @param na.rm (`flag`)\cr whether `NA` values should be removed from `x` prior to analysis.
#' @param na_str (`string`)\cr string used to replace all `NA` or empty values in the output.
#' @param nested (`flag`)\cr whether this layout instruction should be applied within the existing layout structure _if
Expand Down
8 changes: 8 additions & 0 deletions R/response_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ tabulate_rsp_subgroups <- function(lyt,
)) {
checkmate::assert_list(riskdiff, null.ok = TRUE)
checkmate::assert_true(all(c("n_tot", "or", "ci") %in% vars))
if ("pval" %in% vars && !"pval" %in% names(df$or)) {
warning(
'The "pval" statistic has been selected but is not present in "df" so it will not be included in the output ',
'table. To include the "pval" statistic, please specify a p-value test when generating "df" via ',
'the "method" argument to `extract_rsp_subgroups()`. If method = "cmh", strata must also be specified via the ',
'"variables" argument to `extract_rsp_subgroups()`.'
)
}

# Create "ci" column from "lcl" and "ucl"
df$or$ci <- combine_vectors(df$or$lcl, df$or$ucl)
Expand Down
2 changes: 1 addition & 1 deletion man/argument_convention.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/d_rsp_subgroups_colvars.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/extract_rsp_subgroups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/h_response_subgroups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions tests/testthat/test-response_subgroups.R
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,24 @@ testthat::test_that("tabulate_rsp_subgroups riskdiff argument works as expected"
res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
})

testthat::test_that("tabulate_rsp_subgroups pval statistic warning works as expected", {
adrs <- adrs_200

df <- extract_rsp_subgroups(
variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "STRATA2")),
data = adrs,
method = NULL,
conf_level = 0.95
)

# warning when no pval in df
expect_warning(
basic_table() %>%
tabulate_rsp_subgroups(
df = df,
vars = c("n", "prop", "n_tot", "or", "ci", "pval")
),
"please specify a p-value test"
)
})

0 comments on commit 7db0da2

Please sign in to comment.