diff --git a/DESCRIPTION b/DESCRIPTION index d4160fd575..e936bc0d7e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.9.4.9004 -Date: 2024-04-29 +Version: 0.9.4.9005 +Date: 2024-05-10 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 0ff3ba7018..38ce92a5f6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,13 @@ -# tern 0.9.4.9004 +# tern 0.9.4.9005 ### Enhancements * Added `facet_var` to `g_lineplot` to allow plot faceting by a factor variable. * Updated `g_lineplot` legend to follow factor levels set by users. * Added examples and tests for `label_all` parameter to `extract_survival_biomarkers` and `extract_survival_subgroups`. +### Bug Fixes +* Fixed bug in `s_ancova` that prevented statistics from being printed when arm levels include special characters. + ### Miscellaneous * Began deprecation of the unused `label_all` parameter to `tabulate_survival_biomarkers` and `tabulate_survival_subgroups`, with redirection to the same parameter in their associated `extract_*` functions. diff --git a/R/summarize_ancova.R b/R/summarize_ancova.R index e80f8d7d58..2ccc523c36 100644 --- a/R/summarize_ancova.R +++ b/R/summarize_ancova.R @@ -167,7 +167,9 @@ s_ancova <- function(df, adjust = "none" ) - contrast_lvls <- gsub(paste0(" - ", .ref_group[[arm]][1], ".*"), "", sum_contrasts$contrast) + contrast_lvls <- gsub( + "^\\(|\\)$", "", gsub(paste0(" - \\(*", .ref_group[[arm]][1], ".*"), "", sum_contrasts$contrast) + ) if (!is.null(interaction_item)) { sum_contrasts_level <- sum_contrasts[grepl(sum_level, contrast_lvls, fixed = TRUE), ] } else { diff --git a/inst/WORDLIST b/inst/WORDLIST index 8ecc899145..7d919420c7 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -7,7 +7,6 @@ ADTTE AE ANCOVA Agresti -Bové Byar's CDISC CMH @@ -27,7 +26,6 @@ Newcombe Pre Rua SMQ -Sabanés Satterthwaite Schouten TLG diff --git a/tests/testthat/_snaps/summarize_ancova.md b/tests/testthat/_snaps/summarize_ancova.md index caefabf76e..3cd2e456b2 100644 --- a/tests/testthat/_snaps/summarize_ancova.md +++ b/tests/testthat/_snaps/summarize_ancova.md @@ -109,13 +109,27 @@ Code res Output - ARM A ARM B (x) ARM C - (N=69) (N=73) (N=58) - —————————————————————————————————————————————————————————————— - Unadjusted comparison - n 552 584 464 - Mean 0.01 0.01 -0.05 - Difference in Means 0.06 0.06 - 95% CI (-0.07, 0.19) (-0.06, 0.19) - p-value 0.3442 0.3186 + ARM A ARM B (x) ARM C + (N=69) (N=73) (N=58) + —————————————————————————————————————————————————————————— + Unadjusted comparison + n 552 584 464 + Mean 0.01 0.01 -0.05 + Difference in Means 0.06 + 95% CI (-0.07, 0.19) + p-value 0.3442 + +--- + + Code + res + Output + 10mg/kg 20mg/kg 30mg/kg + ———————————————————————————————————————————————————————————————————————— + ARMCD + n 69 73 58 + Adjusted Mean 6.30 6.75 6.16 + Difference in Adjusted Means 0.45 -0.14 + 95% CI (-0.70, 1.60) (-1.36, 1.08) + p-value 0.4433 0.8214 diff --git a/tests/testthat/test-summarize_ancova.R b/tests/testthat/test-summarize_ancova.R index eafef0ef19..05ac191ef3 100644 --- a/tests/testthat/test-summarize_ancova.R +++ b/tests/testthat/test-summarize_ancova.R @@ -206,4 +206,27 @@ testthat::test_that("summarize_ancova works with irregular arm levels", { res <- testthat::expect_silent(result2) testthat::expect_snapshot(res) + + adsl <- adsl |> + mutate( + ARMCD = case_match( + ARMCD, + "ARM A" ~ "10mg/kg", + "ARM B" ~ "20mg/kg", + "ARM C" ~ "30mg/kg" + ) |> factor(levels = paste0(1:3, "0mg/kg")), + ) + + result3 <- basic_table() |> + split_cols_by("ARMCD", ref_group = "10mg/kg") |> + summarize_ancova( + vars = "BMRKR1", + variables = list(arm = "ARMCD"), + conf_level = 0.95, + var_labels = "ARMCD" + ) |> + build_table(adsl) + + res <- testthat::expect_silent(result3) + testthat::expect_snapshot(res) })