From 872f99eb025ae96a5abed8621a2498932b0cf28a Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Thu, 19 Jan 2023 13:01:35 -0500 Subject: [PATCH] Create test snapshots & upgrade to `testthat` 3rd edition (#801) Closes #784 and #656 --- DESCRIPTION | 3 +- NEWS.md | 2 + R/g_step.R | 4 +- tests/testthat/.gitignore | 1 - tests/testthat/_snaps/table_adat03.md | 30 + tests/testthat/_snaps/table_aet01.md | 107 +++ tests/testthat/_snaps/table_aet02.md | 339 +++++++ tests/testthat/_snaps/table_aet02_smq.md | 35 + tests/testthat/_snaps/table_aet03.md | 82 ++ tests/testthat/_snaps/table_aet04.md | 512 ++++++++++ tests/testthat/_snaps/table_aet04_pi.md | 183 ++++ tests/testthat/_snaps/table_aet05.md | 26 + tests/testthat/_snaps/table_aet06.md | 156 +++ tests/testthat/_snaps/table_aet06_smq.md | 68 ++ tests/testthat/_snaps/table_aet07.md | 24 + tests/testthat/_snaps/table_aet09.md | 77 ++ tests/testthat/_snaps/table_aet09_smq.md | 40 + tests/testthat/_snaps/table_aet10.md | 13 + tests/testthat/_snaps/table_aovt01.md | 65 ++ tests/testthat/_snaps/table_cmt01.md | 95 ++ tests/testthat/_snaps/table_cmt02_pt.md | 20 + tests/testthat/_snaps/table_coxt01.md | 78 ++ tests/testthat/_snaps/table_coxt02.md | 28 + tests/testthat/_snaps/table_disclosures.md | 124 +++ tests/testthat/_snaps/table_dmt01.md | 123 +++ tests/testthat/_snaps/table_dort01.md | 100 ++ tests/testthat/_snaps/table_dst01.md | 51 + tests/testthat/_snaps/table_dth01.md | 88 ++ tests/testthat/_snaps/table_egt01.md | 49 + tests/testthat/_snaps/table_egt02.md | 38 + tests/testthat/_snaps/table_egt03.md | 101 ++ tests/testthat/_snaps/table_egt04.md | 20 + tests/testthat/_snaps/table_egt05_qtcat.md | 77 ++ tests/testthat/_snaps/table_ent.md | 464 +++++++++ tests/testthat/_snaps/table_ext01.md | 95 ++ tests/testthat/_snaps/table_fstg02.md | 68 ++ tests/testthat/_snaps/table_lbt01.md | 39 + tests/testthat/_snaps/table_lbt02.md | 39 + tests/testthat/_snaps/table_lbt03.md | 39 + tests/testthat/_snaps/table_lbt04.md | 20 + tests/testthat/_snaps/table_lbt05.md | 89 ++ tests/testthat/_snaps/table_lbt06.md | 55 ++ tests/testthat/_snaps/table_lbt07.md | 36 + tests/testthat/_snaps/table_lbt08.md | 36 + tests/testthat/_snaps/table_lbt14.md | 187 ++++ tests/testthat/_snaps/table_lgrt02.md | 110 +++ tests/testthat/_snaps/table_mht01.md | 109 +++ tests/testthat/_snaps/table_onct05.md | 65 ++ tests/testthat/_snaps/table_pdt01.md | 37 + tests/testthat/_snaps/table_pdt02.md | 16 + tests/testthat/_snaps/table_pkct01.md | 100 ++ tests/testthat/_snaps/table_pkpt02.md | 64 ++ tests/testthat/_snaps/table_pkpt03.md | 49 + tests/testthat/_snaps/table_pkpt04.md | 80 ++ tests/testthat/_snaps/table_pkpt05.md | 55 ++ tests/testthat/_snaps/table_pkpt06.md | 32 + tests/testthat/_snaps/table_pkpt07.md | 37 + tests/testthat/_snaps/table_rspt01.md | 155 +++ tests/testthat/_snaps/table_ttet01.md | 188 ++++ tests/testthat/_snaps/table_vst01.md | 60 ++ tests/testthat/_snaps/table_vst02.md | 56 ++ tests/testthat/test-abnormal_by_baseline.R | 5 +- tests/testthat/test-combination_function.R | 10 +- tests/testthat/test-compare_variables.R | 18 +- .../testthat/test-count_patients_with_event.R | 2 +- tests/testthat/test-coxph.R | 2 +- tests/testthat/test-coxreg.R | 13 +- tests/testthat/test-decorate_grob.R | 4 +- tests/testthat/test-estimate_incidence_rate.R | 2 +- tests/testthat/test-estimate_proportion.R | 36 +- tests/testthat/test-fit_rsp_step.R | 8 +- tests/testthat/test-fit_survival_step.R | 6 +- tests/testthat/test-g_forest.R | 51 + tests/testthat/test-g_step.R | 16 +- .../test-h_response_biomarkers_subgroups.R | 4 +- tests/testthat/test-h_response_subgroups.R | 18 +- tests/testthat/test-h_step.R | 76 +- .../test-h_survival_biomarkers_subgroups.R | 2 +- .../test-h_survival_duration_subgroups.R | 23 +- tests/testthat/test-kaplan_meier_plot.R | 6 +- tests/testthat/test-logistic_regression.R | 108 +-- tests/testthat/test-make_afun.R | 8 +- tests/testthat/test-odds_ratio.R | 3 +- tests/testthat/test-prop_diff.R | 32 +- tests/testthat/test-prune_occurrences.R | 2 +- tests/testthat/test-response_subgroups.R | 16 +- tests/testthat/test-rtables_access.R | 2 +- tests/testthat/test-score_occurrences.R | 6 +- tests/testthat/test-split_cols_by_groups.R | 6 +- tests/testthat/test-summarize_change.R | 2 +- tests/testthat/test-summarize_glm_count.R | 11 +- tests/testthat/test-summarize_variables.R | 20 +- .../test-survival_duration_subgroups.R | 8 +- tests/testthat/test-table_adat03.R | 21 +- tests/testthat/test-table_aet01.R | 116 +-- tests/testthat/test-table_aet02.R | 889 +----------------- tests/testthat/test-table_aet02_smq.R | 88 +- tests/testthat/test-table_aet03.R | 65 +- tests/testthat/test-table_aet04.R | 532 +---------- tests/testthat/test-table_aet04_pi.R | 252 +---- tests/testthat/test-table_aet05.R | 34 +- tests/testthat/test-table_aet06.R | 207 +--- tests/testthat/test-table_aet06_smq.R | 91 +- tests/testthat/test-table_aet07.R | 30 +- tests/testthat/test-table_aet09.R | 297 +----- tests/testthat/test-table_aet09_smq.R | 53 +- tests/testthat/test-table_aet10.R | 20 +- tests/testthat/test-table_aovt01.R | 46 +- tests/testthat/test-table_cmt01.R | 117 +-- tests/testthat/test-table_cmt02_pt.R | 25 +- tests/testthat/test-table_coxt01.R | 82 +- tests/testthat/test-table_coxt02.R | 31 +- tests/testthat/test-table_disclosures.R | 128 +-- tests/testthat/test-table_dmt01.R | 117 +-- tests/testthat/test-table_dort01.R | 97 +- tests/testthat/test-table_dst01.R | 60 +- tests/testthat/test-table_dth01.R | 98 +- tests/testthat/test-table_egt01.R | 63 +- tests/testthat/test-table_egt02.R | 47 +- tests/testthat/test-table_egt03.R | 94 +- tests/testthat/test-table_egt04.R | 22 +- tests/testthat/test-table_egt05_qtcat.R | 57 +- tests/testthat/test-table_ent.R | 774 +-------------- tests/testthat/test-table_ext01.R | 77 +- tests/testthat/test-table_fstg02.R | 79 +- tests/testthat/test-table_lbt01.R | 45 +- tests/testthat/test-table_lbt02.R | 31 +- tests/testthat/test-table_lbt03.R | 31 +- tests/testthat/test-table_lbt04.R | 22 +- tests/testthat/test-table_lbt05.R | 75 +- tests/testthat/test-table_lbt06.R | 48 +- tests/testthat/test-table_lbt07.R | 129 +-- tests/testthat/test-table_lbt08.R | 31 +- tests/testthat/test-table_lbt14.R | 158 +--- tests/testthat/test-table_lgrt02.R | 116 +-- tests/testthat/test-table_mht01.R | 117 +-- tests/testthat/test-table_onct05.R | 76 +- tests/testthat/test-table_pdt01.R | 41 +- tests/testthat/test-table_pdt02.R | 21 +- tests/testthat/test-table_pkct01.R | 78 +- tests/testthat/test-table_pkpt02.R | 56 ++ tests/testthat/test-table_pkpt02_04_06.R | 213 ----- tests/testthat/test-table_pkpt03.R | 81 ++ tests/testthat/test-table_pkpt03_05_07.R | 253 ----- tests/testthat/test-table_pkpt04.R | 56 ++ tests/testthat/test-table_pkpt05.R | 81 ++ tests/testthat/test-table_pkpt06.R | 62 ++ tests/testthat/test-table_pkpt07.R | 88 ++ tests/testthat/test-table_rspt01.R | 166 +--- tests/testthat/test-table_ttet01.R | 162 +--- tests/testthat/test-table_vst01.R | 63 +- tests/testthat/test-table_vst02.R | 60 +- tests/testthat/test-test_proportion_diff.R | 14 +- tests/testthat/test-utils_factor.R | 10 +- tests/testthat/test-utils_rtables.R | 2 +- 155 files changed, 6243 insertions(+), 6517 deletions(-) delete mode 100644 tests/testthat/.gitignore create mode 100644 tests/testthat/_snaps/table_adat03.md create mode 100644 tests/testthat/_snaps/table_aet01.md create mode 100644 tests/testthat/_snaps/table_aet02.md create mode 100644 tests/testthat/_snaps/table_aet02_smq.md create mode 100644 tests/testthat/_snaps/table_aet03.md create mode 100644 tests/testthat/_snaps/table_aet04.md create mode 100644 tests/testthat/_snaps/table_aet04_pi.md create mode 100644 tests/testthat/_snaps/table_aet05.md create mode 100644 tests/testthat/_snaps/table_aet06.md create mode 100644 tests/testthat/_snaps/table_aet06_smq.md create mode 100644 tests/testthat/_snaps/table_aet07.md create mode 100644 tests/testthat/_snaps/table_aet09.md create mode 100644 tests/testthat/_snaps/table_aet09_smq.md create mode 100644 tests/testthat/_snaps/table_aet10.md create mode 100644 tests/testthat/_snaps/table_aovt01.md create mode 100644 tests/testthat/_snaps/table_cmt01.md create mode 100644 tests/testthat/_snaps/table_cmt02_pt.md create mode 100644 tests/testthat/_snaps/table_coxt01.md create mode 100644 tests/testthat/_snaps/table_coxt02.md create mode 100644 tests/testthat/_snaps/table_disclosures.md create mode 100644 tests/testthat/_snaps/table_dmt01.md create mode 100644 tests/testthat/_snaps/table_dort01.md create mode 100644 tests/testthat/_snaps/table_dst01.md create mode 100644 tests/testthat/_snaps/table_dth01.md create mode 100644 tests/testthat/_snaps/table_egt01.md create mode 100644 tests/testthat/_snaps/table_egt02.md create mode 100644 tests/testthat/_snaps/table_egt03.md create mode 100644 tests/testthat/_snaps/table_egt04.md create mode 100644 tests/testthat/_snaps/table_egt05_qtcat.md create mode 100644 tests/testthat/_snaps/table_ent.md create mode 100644 tests/testthat/_snaps/table_ext01.md create mode 100644 tests/testthat/_snaps/table_fstg02.md create mode 100644 tests/testthat/_snaps/table_lbt01.md create mode 100644 tests/testthat/_snaps/table_lbt02.md create mode 100644 tests/testthat/_snaps/table_lbt03.md create mode 100644 tests/testthat/_snaps/table_lbt04.md create mode 100644 tests/testthat/_snaps/table_lbt05.md create mode 100644 tests/testthat/_snaps/table_lbt06.md create mode 100644 tests/testthat/_snaps/table_lbt07.md create mode 100644 tests/testthat/_snaps/table_lbt08.md create mode 100644 tests/testthat/_snaps/table_lbt14.md create mode 100644 tests/testthat/_snaps/table_lgrt02.md create mode 100644 tests/testthat/_snaps/table_mht01.md create mode 100644 tests/testthat/_snaps/table_onct05.md create mode 100644 tests/testthat/_snaps/table_pdt01.md create mode 100644 tests/testthat/_snaps/table_pdt02.md create mode 100644 tests/testthat/_snaps/table_pkct01.md create mode 100644 tests/testthat/_snaps/table_pkpt02.md create mode 100644 tests/testthat/_snaps/table_pkpt03.md create mode 100644 tests/testthat/_snaps/table_pkpt04.md create mode 100644 tests/testthat/_snaps/table_pkpt05.md create mode 100644 tests/testthat/_snaps/table_pkpt06.md create mode 100644 tests/testthat/_snaps/table_pkpt07.md create mode 100644 tests/testthat/_snaps/table_rspt01.md create mode 100644 tests/testthat/_snaps/table_ttet01.md create mode 100644 tests/testthat/_snaps/table_vst01.md create mode 100644 tests/testthat/_snaps/table_vst02.md create mode 100644 tests/testthat/test-g_forest.R create mode 100644 tests/testthat/test-table_pkpt02.R delete mode 100644 tests/testthat/test-table_pkpt02_04_06.R create mode 100644 tests/testthat/test-table_pkpt03.R delete mode 100644 tests/testthat/test-table_pkpt03_05_07.R create mode 100644 tests/testthat/test-table_pkpt04.R create mode 100644 tests/testthat/test-table_pkpt05.R create mode 100644 tests/testthat/test-table_pkpt06.R create mode 100644 tests/testthat/test-table_pkpt07.R diff --git a/DESCRIPTION b/DESCRIPTION index d31172f99a..26236485e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,7 +55,7 @@ Suggests: scda (>= 0.1.5), scda.2022 (>= 0.1.3), stringr, - testthat (>= 2.0) + testthat (>= 3.0) VignetteBuilder: knitr RdMacros: @@ -65,6 +65,7 @@ Remotes: insightsengineering/scda.2022@*release, insightsengineering/scda@*release Config/Needs/website: insightsengineering/nesttemplate +Config/testthat/edition: 3 Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) diff --git a/NEWS.md b/NEWS.md index abfedd96e4..fa78eea194 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,6 +17,7 @@ repeat when paginating. * Added `h_row_first_values` function as a more general helper function to retrieve first values from specific rows. +* Replaced table template tests with snapshot testing. ### Bug Fixes * Fixed bug causing incorrect ordering of numeric grade levels when missing @@ -38,6 +39,7 @@ * Renamed `summarize_vars_in_cols` into `analyze_vars_in_cols` to reflect the appropriate `analyze` logic. * Exported function `format_xx`. +* Updated tests to use `testthat` 3rd edition. # tern 0.7.10 diff --git a/R/g_step.R b/R/g_step.R index 1077f114c2..c745f6ae5e 100644 --- a/R/g_step.R +++ b/R/g_step.R @@ -116,14 +116,14 @@ g_step <- function(df, name = "", values = c("CI 95%" = ci_ribbon$fill) ) } - p <- p + + suppressMessages(p <- p + ggplot2::geom_line( ggplot2::aes(y = .data[["y"]], color = legend_names[1]), linetype = est$lty ) + scale_colour_manual( name = "", values = c("Estimate" = "blue") - ) + )) p <- p + ggplot2::labs(x = attrs$biomarker, y = attrs$estimate) if (use_percentile) { diff --git a/tests/testthat/.gitignore b/tests/testthat/.gitignore deleted file mode 100644 index 016f806654..0000000000 --- a/tests/testthat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/tests/ diff --git a/tests/testthat/_snaps/table_adat03.md b/tests/testthat/_snaps/table_adat03.md new file mode 100644 index 0000000000..e0c84f3bda --- /dev/null +++ b/tests/testthat/_snaps/table_adat03.md @@ -0,0 +1,30 @@ +# ADAT03 is produced correctly + + Code + res + Output + Treatment Group + Visit Total Number Samples with + of Measurable Concentration + Samples {1} Mean SD Median Minimum Maximum CV (%) Geometric Mean ≤ 15μg/mL {2} + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X (N=1206) + Day 1 + 938 8.227e+00 7.351e+00 1.131e+01 0.000e+00 1.986e+01 89.4 NA 738 (78.7%) + Day 2 + 268 1.344e+01 1.351e+00 1.330e+01 1.075e+01 1.646e+01 10.0 1.338e+01 228 (85.1%) + + C: Combination (N=2112) + Day 1 + 1584 1.469e+01 1.237e+01 1.451e+01 0.000e+00 3.947e+01 84.3 NA 836 (52.8%) + Day 2 + 528 2.018e+01 7.129e+00 1.888e+01 1.073e+01 3.259e+01 35.3 1.891e+01 210 (39.8%) + + Overall 3318 1.363e+01 1.059e+01 1.377e+01 0.000e+00 3.947e+01 77.7 NA 2012 (60.6%) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + {1} - footnote1 + {2} - footnote2 + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + diff --git a/tests/testthat/_snaps/table_aet01.md b/tests/testthat/_snaps/table_aet01.md new file mode 100644 index 0000000000..51d86c90f5 --- /dev/null +++ b/tests/testthat/_snaps/table_aet01.md @@ -0,0 +1,107 @@ +# Safety Summary Variant 1 works as expected + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91.0%) 123 (91.8%) 120 (90.9%) + Total AEs 609 622 703 + Total number of deaths 25 (18.66%) 23 (17.16%) 22 (16.67%) + Total number of patients withdrawn from study due to an AE 3 (2.24%) 6 (4.48%) 5 (3.79%) + Total number of patients with at least one + AE with fatal outcome 76 (56.7%) 70 (52.2%) 75 (56.8%) + Serious AE 104 (77.6%) 101 (75.4%) 99 (75.0%) + Serious AE leading to withdrawal from treatment 9 (6.7%) 6 (4.5%) 11 (8.3%) + Serious AE leading to dose modification/interruption 22 (16.4%) 26 (19.4%) 29 (22.0%) + Related Serious AE 76 (56.7%) 70 (52.2%) 75 (56.8%) + AE leading to withdrawal from treatment 27 (20.1%) 26 (19.4%) 30 (22.7%) + AE leading to dose modification/interruption 66 (49.3%) 76 (56.7%) 74 (56.1%) + Related AE 105 (78.4%) 108 (80.6%) 109 (82.6%) + Related AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 8 (6.1%) + Related AE leading to dose modification/interruption 29 (21.6%) 38 (28.4%) 38 (28.8%) + Grade 3-5 AE 109 (81.3%) 104 (77.6%) 109 (82.6%) + +# Safety Summary Variant 2 (with Medical Concepts Section) works as expected + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91.0%) 123 (91.8%) 120 (90.9%) + Total AEs 609 622 703 + Total number of deaths 25 (18.66%) 23 (17.16%) 22 (16.67%) + Total number of patients withdrawn from study due to an AE 3 (2.24%) 6 (4.48%) 5 (3.79%) + Total number of patients with at least one + AE with fatal outcome 76 (56.7%) 70 (52.2%) 75 (56.8%) + Serious AE 104 (77.6%) 101 (75.4%) 99 (75.0%) + Serious AE leading to withdrawal from treatment 9 (6.7%) 6 (4.5%) 11 (8.3%) + Serious AE leading to dose modification/interruption 22 (16.4%) 26 (19.4%) 29 (22.0%) + Related Serious AE 76 (56.7%) 70 (52.2%) 75 (56.8%) + AE leading to withdrawal from treatment 27 (20.1%) 26 (19.4%) 30 (22.7%) + AE leading to dose modification/interruption 66 (49.3%) 76 (56.7%) 74 (56.1%) + Related AE 105 (78.4%) 108 (80.6%) 109 (82.6%) + Related AE leading to withdrawal from treatment 6 (4.5%) 12 (9.0%) 8 (6.1%) + Related AE leading to dose modification/interruption 29 (21.6%) 38 (28.4%) 38 (28.8%) + Grade 3-5 AE 109 (81.3%) 104 (77.6%) 109 (82.6%) + Total number of patients with at least one + C.1.1.1.3/B.2.2.3.1 AESI (BROAD) 72 (53.7%) 79 (59.0%) 75 (56.8%) + SMQ 02 Reference Name 0 0 0 + D.2.1.5.3/A.1.1.1.1 AESI 74 (55.2%) 80 (59.7%) 87 (65.9%) + +# Safety Summary Variant 3 (with Modified Rows) works as expected + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91.0%) 123 (91.8%) 120 (90.9%) + Total AEs 609 622 703 + Total number of deaths 25 (18.66%) 23 (17.16%) 22 (16.67%) + Total number of patients withdrawn from study due to an AE 3 (2.24%) 6 (4.48%) 5 (3.79%) + Total number of patients withdrawn informed consent 1 (0.75%) 1 (0.75%) 1 (0.76%) + Total number of patients with at least one + AE with fatal outcome 76 (56.7%) 70 (52.2%) 75 (56.8%) + Serious AE 104 (77.6%) 101 (75.4%) 99 (75.0%) + AE leading to withdrawal from treatment 27 (20.1%) 26 (19.4%) 30 (22.7%) + Related AE 105 (78.4%) 108 (80.6%) 109 (82.6%) + Grade 3-5 AE 109 (81.3%) 104 (77.6%) 109 (82.6%) + Grade 4/5 AE 91 (67.9%) 90 (67.2%) 93 (70.5%) + +# Safety Summary Variant 4 (with Rows Counting Events and Additional Sections) works as expected + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91.0%) 123 (91.8%) 120 (90.9%) + Total AEs 609 622 703 + Total number of deaths 25 (18.66%) 23 (17.16%) 22 (16.67%) + Total number of patients withdrawn from study due to an AE 3 (2.24%) 6 (4.48%) 5 (3.79%) + Total number of patients with at least one + AE with fatal outcome 76 (56.7%) 70 (52.2%) 75 (56.8%) + Serious AE 104 (77.6%) 101 (75.4%) 99 (75.0%) + AE leading to withdrawal from treatment 27 (20.1%) 26 (19.4%) 30 (22.7%) + AE leading to dose modification/interruption 66 (49.3%) 76 (56.7%) 74 (56.1%) + Related AE 105 (78.4%) 108 (80.6%) 109 (82.6%) + Grade 3-5 AE 109 (81.3%) 104 (77.6%) 109 (82.6%) + Total number of unique preferred terms which are + Serious AE 4 4 4 + AE leading to dose modification/interruption 8 8 8 + Related AE 5 5 5 + Grade 3-5 AE 5 5 5 + Grade 4/5 3 3 3 + Total number of adverse events which are + Serious AE 249 255 282 + AE leading to dose modification/interruption 116 122 137 + Related AE 282 299 336 + Grade 3-5 AE 303 291 327 + Grade 4/5 172 174 197 + diff --git a/tests/testthat/_snaps/table_aet02.md b/tests/testthat/_snaps/table_aet02.md new file mode 100644 index 0000000000..87ef4c70e4 --- /dev/null +++ b/tests/testthat/_snaps/table_aet02.md @@ -0,0 +1,339 @@ +# AET02 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91%) 123 (91.8%) 120 (90.9%) 365 (91.2%) + Overall total number of events 609 622 703 1934 + cl A.1 + Total number of patients with at least one adverse event 78 (58.2%) 75 (56%) 89 (67.4%) 242 (60.5%) + Total number of events 132 130 160 422 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) + dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) + cl B.2 + Total number of patients with at least one adverse event 79 (59%) 74 (55.2%) 85 (64.4%) 238 (59.5%) + Total number of events 129 138 143 410 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) + cl D.1 + Total number of patients with at least one adverse event 79 (59%) 67 (50%) 80 (60.6%) 226 (56.5%) + Total number of events 127 106 135 368 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) + dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) + cl D.2 + Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + Total number of events 62 72 74 208 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + cl B.1 + Total number of patients with at least one adverse event 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + Total number of events 56 60 62 178 + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + cl C.2 + Total number of patients with at least one adverse event 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + Total number of events 48 53 65 166 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + cl C.1 + Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33%) + Total number of events 55 63 64 182 + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) + +# AET02 variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91%) 123 (91.8%) 120 (90.9%) 365 (91.2%) + Overall total number of events 609 622 703 1934 + cl A.1 + Total number of patients with at least one adverse event 78 (58.2%) 75 (56%) 89 (67.4%) 242 (60.5%) + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) + dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) + Total number of events 132 130 160 422 + cl B.2 + Total number of patients with at least one adverse event 79 (59%) 74 (55.2%) 85 (64.4%) 238 (59.5%) + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) + Total number of events 129 138 143 410 + cl D.1 + Total number of patients with at least one adverse event 79 (59%) 67 (50%) 80 (60.6%) 226 (56.5%) + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) + dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) + Total number of events 127 106 135 368 + cl D.2 + Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + Total number of events 62 72 74 208 + cl B.1 + Total number of patients with at least one adverse event 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + Total number of events 56 60 62 178 + cl C.2 + Total number of patients with at least one adverse event 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + Total number of events 48 53 65 166 + cl C.1 + Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33%) + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) + Total number of events 55 63 64 182 + +# AET02 variant 3 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91%) 123 (91.8%) 120 (90.9%) + Overall total number of events 609 622 703 + cl A.1 + Total number of patients with at least one adverse event 78 (58.2%) 75 (56%) 89 (67.4%) + Total number of events 132 130 160 + hlt A.1.1.1 + Total number of patients with at least one adverse event 78 (58.2%) 75 (56%) 89 (67.4%) + Total number of events 132 130 160 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) + cl B.2 + Total number of patients with at least one adverse event 79 (59%) 74 (55.2%) 85 (64.4%) + Total number of events 129 138 143 + hlt B.2.2.3 + Total number of patients with at least one adverse event 48 (35.8%) 54 (40.3%) 51 (38.6%) + Total number of events 64 76 77 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + hlt B.2.1.2 + Total number of patients with at least one adverse event 49 (36.6%) 44 (32.8%) 52 (39.4%) + Total number of events 65 62 66 + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) + cl D.1 + Total number of patients with at least one adverse event 79 (59%) 67 (50%) 80 (60.6%) + Total number of events 127 106 135 + hlt D.1.1.1 + Total number of patients with at least one adverse event 50 (37.3%) 42 (31.3%) 51 (38.6%) + Total number of events 61 51 71 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + hlt D.1.1.4 + Total number of patients with at least one adverse event 48 (35.8%) 42 (31.3%) 50 (37.9%) + Total number of events 66 55 64 + dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) + cl D.2 + Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%) + Total number of events 62 72 74 + hlt D.2.1.5 + Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 57 (43.2%) + Total number of events 62 72 74 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl B.1 + Total number of patients with at least one adverse event 47 (35.1%) 49 (36.6%) 43 (32.6%) + Total number of events 56 60 62 + hlt B.1.1.1 + Total number of patients with at least one adverse event 47 (35.1%) 49 (36.6%) 43 (32.6%) + Total number of events 56 60 62 + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) + cl C.2 + Total number of patients with at least one adverse event 35 (26.1%) 48 (35.8%) 55 (41.7%) + Total number of events 48 53 65 + hlt C.2.1.2 + Total number of patients with at least one adverse event 35 (26.1%) 48 (35.8%) 55 (41.7%) + Total number of events 48 53 65 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl C.1 + Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%) + Total number of events 55 63 64 + hlt C.1.1.1 + Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 43 (32.6%) + Total number of events 55 63 64 + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET02 variant 4 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91%) 123 (91.8%) 120 (90.9%) + Total number of events 609 622 703 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET02 variant 5 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 122 (91%) 123 (91.8%) 0 + Overall total number of events 609 622 0 + cl A.1 + Total number of patients with at least one adverse event 78 (58.2%) 75 (56%) 0 + Total number of events 132 130 0 + dcd A.1.1.1.2 48 (35.8%) 48 (35.8%) 0 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 0 + cl B.2 + Total number of patients with at least one adverse event 79 (59%) 74 (55.2%) 0 + Total number of events 129 138 0 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 0 + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 0 + cl D.1 + Total number of patients with at least one adverse event 79 (59%) 67 (50%) 0 + Total number of events 127 106 0 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 0 + dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 0 + cl D.2 + Total number of patients with at least one adverse event 47 (35.1%) 58 (43.3%) 0 + Total number of events 62 72 0 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 0 + cl B.1 + Total number of patients with at least one adverse event 47 (35.1%) 49 (36.6%) 0 + Total number of events 56 60 0 + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 0 + cl C.1 + Total number of patients with at least one adverse event 43 (32.1%) 46 (34.3%) 0 + Total number of events 55 63 0 + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 0 + cl C.2 + Total number of patients with at least one adverse event 35 (26.1%) 48 (35.8%) 0 + Total number of events 48 53 0 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 0 + +# AET02 variant 6 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl D.2 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET02 variant 7 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————— + cl A.1 + hlt A.1.1.1 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + hlt B.2.2.3 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl D.2 + hlt D.2.1.5 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + hlt C.2.1.2 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET02 variant 8 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl D.2 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET02 variant 9 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) + cl D.2 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET02 variant 10 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + dcd B.2.1.2.1 49 (36.6%) 44 (32.8%) 52 (39.4%) + cl D.1 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.4.2 48 (35.8%) 42 (31.3%) 50 (37.9%) + cl D.2 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET02 variant 11 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————— + cl B.2 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl D.2 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + +# AET02 variant 12 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl D.1 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + cl D.2 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + diff --git a/tests/testthat/_snaps/table_aet02_smq.md b/tests/testthat/_snaps/table_aet02_smq.md new file mode 100644 index 0000000000..939fadc543 --- /dev/null +++ b/tests/testthat/_snaps/table_aet02_smq.md @@ -0,0 +1,35 @@ +# AET02SMQ variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 72 (53.7%) 79 (59%) 75 (56.8%) + SMQ01NAM + Total number of patients with at least one adverse event 72 (53.7%) 79 (59%) 75 (56.8%) + Overall total number of events 119 139 141 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET02SMQ variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 95 (70.9%) 103 (76.9%) 108 (81.8%) + CQ01NAM + Total number of patients with at least one adverse event 74 (55.2%) 80 (59.7%) 87 (65.9%) + Overall total number of events 126 134 162 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) + SMQ01NAM + Total number of patients with at least one adverse event 72 (53.7%) 79 (59%) 75 (56.8%) + Overall total number of events 119 139 141 + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + diff --git a/tests/testthat/_snaps/table_aet03.md b/tests/testthat/_snaps/table_aet03.md new file mode 100644 index 0000000000..d2133e16af --- /dev/null +++ b/tests/testthat/_snaps/table_aet03.md @@ -0,0 +1,82 @@ +# AET03 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————— + - Any Intensity - 122 (91.0%) 123 (91.8%) 120 (90.9%) + MILD 7 (5.2%) 9 (6.7%) 4 (3.0%) + MODERATE 23 (17.2%) 24 (17.9%) 23 (17.4%) + SEVERE 91 (67.9%) 89 (66.4%) 91 (68.9%) + LIFE THREATENING 1 (0.7%) 1 (0.7%) 2 (1.5%) + cl A.1 + - Any Intensity - 78 (58.2%) 75 (56.0%) 89 (67.4%) + MILD 30 (22.4%) 27 (20.1%) 39 (29.5%) + MODERATE 47 (35.1%) 48 (35.8%) 49 (37.1%) + LIFE THREATENING 1 (0.7%) 0 1 (0.8%) + dcd A.1.1.1.1 + - Any Intensity - 50 (37.3%) 45 (33.6%) 63 (47.7%) + MILD 50 (37.3%) 45 (33.6%) 62 (47.0%) + LIFE THREATENING 0 0 1 (0.8%) + dcd A.1.1.1.2 + - Any Intensity - 48 (35.8%) 48 (35.8%) 50 (37.9%) + MODERATE 47 (35.1%) 48 (35.8%) 49 (37.1%) + LIFE THREATENING 1 (0.7%) 0 1 (0.8%) + cl B.2 + - Any Intensity - 79 (59.0%) 74 (55.2%) 85 (64.4%) + MILD 30 (22.4%) 30 (22.4%) 33 (25.0%) + MODERATE 48 (35.8%) 44 (32.8%) 51 (38.6%) + LIFE THREATENING 1 (0.7%) 0 1 (0.8%) + dcd B.2.2.3.1 + - Any Intensity - 48 (35.8%) 54 (40.3%) 51 (38.6%) + MILD 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd B.2.1.2.1 + - Any Intensity - 49 (36.6%) 44 (32.8%) 52 (39.4%) + MODERATE 48 (35.8%) 44 (32.8%) 51 (38.6%) + LIFE THREATENING 1 (0.7%) 0 1 (0.8%) + cl D.1 + - Any Intensity - 79 (59.0%) 67 (50.0%) 80 (60.6%) + MODERATE 28 (20.9%) 25 (18.7%) 29 (22.0%) + SEVERE 50 (37.3%) 42 (31.3%) 49 (37.1%) + LIFE THREATENING 1 (0.7%) 0 2 (1.5%) + dcd D.1.1.1.1 + - Any Intensity - 50 (37.3%) 42 (31.3%) 51 (38.6%) + SEVERE 50 (37.3%) 42 (31.3%) 50 (37.9%) + LIFE THREATENING 0 0 1 (0.8%) + dcd D.1.1.4.2 + - Any Intensity - 48 (35.8%) 42 (31.3%) 50 (37.9%) + MODERATE 47 (35.1%) 42 (31.3%) 49 (37.1%) + LIFE THREATENING 1 (0.7%) 0 1 (0.8%) + cl D.2 + - Any Intensity - 47 (35.1%) 58 (43.3%) 57 (43.2%) + MILD 47 (35.1%) 58 (43.3%) 56 (42.4%) + LIFE THREATENING 0 0 1 (0.8%) + dcd D.2.1.5.3 + - Any Intensity - 47 (35.1%) 58 (43.3%) 57 (43.2%) + MILD 47 (35.1%) 58 (43.3%) 56 (42.4%) + LIFE THREATENING 0 0 1 (0.8%) + cl B.1 + - Any Intensity - 47 (35.1%) 49 (36.6%) 43 (32.6%) + SEVERE 47 (35.1%) 48 (35.8%) 43 (32.6%) + LIFE THREATENING 0 1 (0.7%) 0 + dcd B.1.1.1.1 + - Any Intensity - 47 (35.1%) 49 (36.6%) 43 (32.6%) + SEVERE 47 (35.1%) 48 (35.8%) 43 (32.6%) + LIFE THREATENING 0 1 (0.7%) 0 + cl C.2 + - Any Intensity - 35 (26.1%) 48 (35.8%) 55 (41.7%) + MODERATE 35 (26.1%) 48 (35.8%) 54 (40.9%) + LIFE THREATENING 0 0 1 (0.8%) + dcd C.2.1.2.1 + - Any Intensity - 35 (26.1%) 48 (35.8%) 55 (41.7%) + MODERATE 35 (26.1%) 48 (35.8%) 54 (40.9%) + LIFE THREATENING 0 0 1 (0.8%) + cl C.1 + - Any Intensity - 43 (32.1%) 46 (34.3%) 43 (32.6%) + SEVERE 43 (32.1%) 46 (34.3%) 43 (32.6%) + dcd C.1.1.1.3 + - Any Intensity - 43 (32.1%) 46 (34.3%) 43 (32.6%) + SEVERE 43 (32.1%) 46 (34.3%) 43 (32.6%) + diff --git a/tests/testthat/_snaps/table_aet04.md b/tests/testthat/_snaps/table_aet04.md new file mode 100644 index 0000000000..8096815735 --- /dev/null +++ b/tests/testthat/_snaps/table_aet04.md @@ -0,0 +1,512 @@ +# AET04 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) + Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) + 1 7 (5.2%) 9 (6.7%) 4 (3.0%) + 2 6 (4.5%) 10 (7.5%) 7 (5.3%) + Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) + 3 18 (13.4%) 14 (10.4%) 16 (12.1%) + 4 15 (11.2%) 20 (14.9%) 18 (13.6%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + cl A.1 + - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) + Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) + 1 30 (22.4%) 27 (20.1%) 39 (29.5%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + dcd A.1.1.1.2 + - Any Grade - 48 (35.8%) 48 (35.8%) 50 (37.9%) + Grade 1-2 48 (35.8%) 48 (35.8%) 50 (37.9%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + cl B.2 + - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) + Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) + 1 30 (22.4%) 30 (22.4%) 33 (25.0%) + Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + dcd B.2.2.3.1 + - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) + Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) + 1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd B.2.1.2.1 + - Any Grade - 49 (36.6%) 44 (32.8%) 52 (39.4%) + Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + cl D.1 + - Any Grade - 79 (59.0%) 67 (50.0%) 80 (60.6%) + Grade 3-4 29 (21.6%) 25 (18.7%) 29 (22.0%) + 3 29 (21.6%) 25 (18.7%) 29 (22.0%) + Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.1.1 + - Any Grade - 50 (37.3%) 42 (31.3%) 51 (38.6%) + Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.4.2 + - Any Grade - 48 (35.8%) 42 (31.3%) 50 (37.9%) + Grade 3-4 48 (35.8%) 42 (31.3%) 50 (37.9%) + 3 48 (35.8%) 42 (31.3%) 50 (37.9%) + cl D.2 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl B.1 + - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) + Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) + dcd B.1.1.1.1 + - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) + Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) + cl C.2 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl C.1 + - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) + Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) + 4 43 (32.1%) 46 (34.3%) 43 (32.6%) + dcd C.1.1.1.3 + - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) + Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) + 4 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET04 variant 2 is produced correctly (Fill in of Treatment Groups) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 0 0 + Grade 1-2 13 (9.7%) 0 0 + 1 7 (5.2%) 0 0 + 2 6 (4.5%) 0 0 + Grade 3-4 33 (24.6%) 0 0 + 3 18 (13.4%) 0 0 + 4 15 (11.2%) 0 0 + Grade 5 76 (56.7%) 0 0 + cl B.2 + - Any Grade - 79 (59.0%) 0 0 + Grade 1-2 30 (22.4%) 0 0 + 1 30 (22.4%) 0 0 + Grade 3-4 49 (36.6%) 0 0 + 3 49 (36.6%) 0 0 + dcd B.2.1.2.1 + - Any Grade - 49 (36.6%) 0 0 + Grade 3-4 49 (36.6%) 0 0 + 3 49 (36.6%) 0 0 + dcd B.2.2.3.1 + - Any Grade - 48 (35.8%) 0 0 + Grade 1-2 48 (35.8%) 0 0 + 1 48 (35.8%) 0 0 + cl D.1 + - Any Grade - 79 (59.0%) 0 0 + Grade 3-4 29 (21.6%) 0 0 + 3 29 (21.6%) 0 0 + Grade 5 50 (37.3%) 0 0 + dcd D.1.1.1.1 + - Any Grade - 50 (37.3%) 0 0 + Grade 5 50 (37.3%) 0 0 + dcd D.1.1.4.2 + - Any Grade - 48 (35.8%) 0 0 + Grade 3-4 48 (35.8%) 0 0 + 3 48 (35.8%) 0 0 + cl A.1 + - Any Grade - 78 (58.2%) 0 0 + Grade 1-2 78 (58.2%) 0 0 + 1 30 (22.4%) 0 0 + 2 48 (35.8%) 0 0 + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 0 0 + Grade 1-2 50 (37.3%) 0 0 + 1 50 (37.3%) 0 0 + dcd A.1.1.1.2 + - Any Grade - 48 (35.8%) 0 0 + Grade 1-2 48 (35.8%) 0 0 + 2 48 (35.8%) 0 0 + cl B.1 + - Any Grade - 47 (35.1%) 0 0 + Grade 5 47 (35.1%) 0 0 + dcd B.1.1.1.1 + - Any Grade - 47 (35.1%) 0 0 + Grade 5 47 (35.1%) 0 0 + cl D.2 + - Any Grade - 47 (35.1%) 0 0 + Grade 1-2 47 (35.1%) 0 0 + 1 47 (35.1%) 0 0 + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 0 0 + Grade 1-2 47 (35.1%) 0 0 + 1 47 (35.1%) 0 0 + cl C.1 + - Any Grade - 43 (32.1%) 0 0 + Grade 3-4 43 (32.1%) 0 0 + 4 43 (32.1%) 0 0 + dcd C.1.1.1.3 + - Any Grade - 43 (32.1%) 0 0 + Grade 3-4 43 (32.1%) 0 0 + 4 43 (32.1%) 0 0 + cl C.2 + - Any Grade - 35 (26.1%) 0 0 + Grade 1-2 35 (26.1%) 0 0 + 2 35 (26.1%) 0 0 + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 0 0 + Grade 1-2 35 (26.1%) 0 0 + 2 35 (26.1%) 0 0 + +# AET04 variant 3 is produced correctly (Fill in of Grades) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) + Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) + 1 7 (5.2%) 9 (6.7%) 4 (3.0%) + 2 6 (4.5%) 10 (7.5%) 7 (5.3%) + Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) + 3 18 (13.4%) 14 (10.4%) 16 (12.1%) + 4 15 (11.2%) 20 (14.9%) 18 (13.6%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + cl A.1 + - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) + Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) + 1 30 (22.4%) 27 (20.1%) 39 (29.5%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + dcd A.1.1.1.2 + - Any Grade - 48 (35.8%) 48 (35.8%) 50 (37.9%) + Grade 1-2 48 (35.8%) 48 (35.8%) 50 (37.9%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + cl B.2 + - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) + Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) + 1 30 (22.4%) 30 (22.4%) 33 (25.0%) + Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + dcd B.2.2.3.1 + - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) + Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) + 1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd B.2.1.2.1 + - Any Grade - 49 (36.6%) 44 (32.8%) 52 (39.4%) + Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + cl D.1 + - Any Grade - 79 (59.0%) 67 (50.0%) 80 (60.6%) + Grade 3-4 29 (21.6%) 25 (18.7%) 29 (22.0%) + 3 29 (21.6%) 25 (18.7%) 29 (22.0%) + Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.1.1 + - Any Grade - 50 (37.3%) 42 (31.3%) 51 (38.6%) + Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.4.2 + - Any Grade - 48 (35.8%) 42 (31.3%) 50 (37.9%) + Grade 3-4 48 (35.8%) 42 (31.3%) 50 (37.9%) + 3 48 (35.8%) 42 (31.3%) 50 (37.9%) + cl D.2 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl B.1 + - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) + Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) + dcd B.1.1.1.1 + - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) + Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) + cl C.2 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl C.1 + - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) + Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) + 4 43 (32.1%) 46 (34.3%) 43 (32.6%) + dcd C.1.1.1.3 + - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) + Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) + 4 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET04 variant 4 is produced correctly (Collapsing of Grades: grades 1&2, grades 3&4&5) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) + Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) + 1 7 (5.2%) 9 (6.7%) 4 (3.0%) + 2 6 (4.5%) 10 (7.5%) 7 (5.3%) + Grade 3-5 109 (81.3%) 104 (77.6%) 109 (82.6%) + 3 18 (13.4%) 14 (10.4%) 16 (12.1%) + 4 15 (11.2%) 20 (14.9%) 18 (13.6%) + 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + cl A.1 + - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) + Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) + 1 30 (22.4%) 27 (20.1%) 39 (29.5%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + dcd A.1.1.1.2 + - Any Grade - 48 (35.8%) 48 (35.8%) 50 (37.9%) + Grade 1-2 48 (35.8%) 48 (35.8%) 50 (37.9%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + cl B.2 + - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) + Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) + 1 30 (22.4%) 30 (22.4%) 33 (25.0%) + Grade 3-5 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + dcd B.2.2.3.1 + - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) + Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) + 1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd B.2.1.2.1 + - Any Grade - 49 (36.6%) 44 (32.8%) 52 (39.4%) + Grade 3-5 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + cl D.1 + - Any Grade - 79 (59.0%) 67 (50.0%) 80 (60.6%) + Grade 3-5 79 (59.0%) 67 (50.0%) 80 (60.6%) + 3 29 (21.6%) 25 (18.7%) 29 (22.0%) + 5 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.1.1 + - Any Grade - 50 (37.3%) 42 (31.3%) 51 (38.6%) + Grade 3-5 50 (37.3%) 42 (31.3%) 51 (38.6%) + 5 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd D.1.1.4.2 + - Any Grade - 48 (35.8%) 42 (31.3%) 50 (37.9%) + Grade 3-5 48 (35.8%) 42 (31.3%) 50 (37.9%) + 3 48 (35.8%) 42 (31.3%) 50 (37.9%) + cl D.2 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl B.1 + - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) + Grade 3-5 47 (35.1%) 49 (36.6%) 43 (32.6%) + 5 47 (35.1%) 49 (36.6%) 43 (32.6%) + dcd B.1.1.1.1 + - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) + Grade 3-5 47 (35.1%) 49 (36.6%) 43 (32.6%) + 5 47 (35.1%) 49 (36.6%) 43 (32.6%) + cl C.2 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl C.1 + - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) + Grade 3-5 43 (32.1%) 46 (34.3%) 43 (32.6%) + 4 43 (32.1%) 46 (34.3%) 43 (32.6%) + dcd C.1.1.1.3 + - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) + Grade 3-5 43 (32.1%) 46 (34.3%) 43 (32.6%) + 4 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET04 variant 6 is produced correctly (with an Incidence Rate of at Least 5%, totals restricted) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————— + - Any Grade - 92 (68.7%) 104 (77.6%) 107 (81.1%) + Grade 1-2 92 (68.7%) 104 (77.6%) 107 (81.1%) + 1 57 (42.5%) 56 (41.8%) 52 (39.4%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl D.2 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl A.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) + Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) + 1 48 (35.8%) 54 (40.3%) 51 (38.6%) + dcd B.2.2.3.1 + - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) + Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) + 1 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl C.2 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET04 variant 8 is produced correctly (with an Incidence Rate of at Least X Patients) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) + Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) + 1 7 (5.2%) 9 (6.7%) 4 (3.0%) + 2 6 (4.5%) 10 (7.5%) 7 (5.3%) + Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) + 3 18 (13.4%) 14 (10.4%) 16 (12.1%) + 4 15 (11.2%) 20 (14.9%) 18 (13.6%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + cl A.1 + - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) + Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) + 1 30 (22.4%) 27 (20.1%) 39 (29.5%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl D.2 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + +# AET04 variant 9 is produced correctlyb(with a Difference in Incidence Rate of at Least X%) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) + Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) + 1 7 (5.2%) 9 (6.7%) 4 (3.0%) + 2 6 (4.5%) 10 (7.5%) 7 (5.3%) + Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) + 3 18 (13.4%) 14 (10.4%) 16 (12.1%) + 4 15 (11.2%) 20 (14.9%) 18 (13.6%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + cl A.1 + - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) + Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) + 1 30 (22.4%) 27 (20.1%) 39 (29.5%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl C.2 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + +# AET04 variant 11 is produced correctly (with Incidence Rate of at Least X%, all SOCs w/o preferred terms removed) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + - Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) + Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) + 1 7 (5.2%) 9 (6.7%) 4 (3.0%) + 2 6 (4.5%) 10 (7.5%) 7 (5.3%) + Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) + 3 18 (13.4%) 14 (10.4%) 16 (12.1%) + 4 15 (11.2%) 20 (14.9%) 18 (13.6%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + cl A.1 + - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) + Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) + 1 30 (22.4%) 27 (20.1%) 39 (29.5%) + 2 48 (35.8%) 48 (35.8%) 50 (37.9%) + dcd A.1.1.1.1 + - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) + Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) + 1 50 (37.3%) 45 (33.6%) 63 (47.7%) + cl B.2 + - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) + Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) + 1 30 (22.4%) 30 (22.4%) 33 (25.0%) + Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) + 3 49 (36.6%) 44 (32.8%) 52 (39.4%) + dcd B.2.2.3.1 + - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) + Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) + 1 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl D.2 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + dcd D.2.1.5.3 + - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) + Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) + 1 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl C.2 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + dcd C.2.1.2.1 + - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) + Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) + 2 35 (26.1%) 48 (35.8%) 55 (41.7%) + diff --git a/tests/testthat/_snaps/table_aet04_pi.md b/tests/testthat/_snaps/table_aet04_pi.md new file mode 100644 index 0000000000..ec649b1dc0 --- /dev/null +++ b/tests/testthat/_snaps/table_aet04_pi.md @@ -0,0 +1,183 @@ +# AET04_PI full table is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + Total number of patients with at least one adverse event 78 (58.2%) 0 0 75 (56%) 0 0 89 (67.4%) 0 0 + dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 + dcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 + cl B.2 + Total number of patients with at least one adverse event 79 (59%) 49 (36.6%) 0 74 (55.2%) 44 (32.8%) 0 85 (64.4%) 52 (39.4%) 0 + dcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 + dcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 + cl D.1 + Total number of patients with at least one adverse event 79 (59%) 48 (35.8%) 50 (37.3%) 67 (50%) 42 (31.3%) 42 (31.3%) 80 (60.6%) 50 (37.9%) 51 (38.6%) + dcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 + dcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 + cl D.2 + Total number of patients with at least one adverse event 47 (35.1%) 0 0 58 (43.3%) 0 0 57 (43.2%) 0 0 + dcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 + cl B.1 + Total number of patients with at least one adverse event 47 (35.1%) 0 47 (35.1%) 49 (36.6%) 0 49 (36.6%) 43 (32.6%) 0 43 (32.6%) + dcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 + cl C.2 + Total number of patients with at least one adverse event 35 (26.1%) 0 0 48 (35.8%) 0 0 55 (41.7%) 0 0 + dcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 + cl C.1 + Total number of patients with at least one adverse event 43 (32.1%) 43 (32.1%) 0 46 (34.3%) 46 (34.3%) 0 43 (32.6%) 43 (32.6%) 0 + dcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 + +# AET04_PI variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 + dcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 + cl B.2 + dcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 + dcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 + cl D.1 + dcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 + dcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 + cl D.2 + dcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 + cl B.1 + dcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 + cl C.2 + dcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 + cl C.1 + dcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 + +# AET04_PI variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 + cl D.1 + dcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 + +# AET04_PI variant 3 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 + cl B.2 + dcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 + cl D.2 + dcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 + cl C.2 + dcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 + +# AET04_PI variant 4 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl C.2 + dcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 + +# AET04_PI variant 5 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 + cl B.2 + dcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 + cl D.1 + dcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 + cl D.2 + dcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 + cl B.1 + dcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 + cl C.2 + dcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 + +# AET04_PI variant 6 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 1-2 (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 37 37 0 0 34 34 0 0 48 48 0 0 + cl B.2 + dcd B.2.2.3.1 36 36 0 0 40 40 0 0 39 39 0 0 + cl D.2 + dcd D.2.1.5.3 35 35 0 0 43 43 0 0 43 43 0 0 + cl C.2 + dcd C.2.1.2.1 26 26 0 0 36 36 0 0 42 42 0 0 + +# AET04_PI variant 7 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 3-5 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + cl A.1 + dcd A.1.1.1.1 37 0 0 0 34 0 0 0 48 0 0 0 + cl B.2 + dcd B.2.2.3.1 36 0 0 0 40 0 0 0 39 0 0 0 + cl D.2 + dcd D.2.1.5.3 35 0 0 0 43 0 0 0 43 0 0 0 + cl C.2 + dcd C.2.1.2.1 26 0 0 0 36 0 0 0 42 0 0 0 + +# AET04_PI variant 8 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) Any Grade (%) Grade 3-4 (%) Grade 5 (%) + (N=134) (N=134) (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + dcd D.2.1.5.3 35 0 0 43 0 0 43 0 0 + dcd A.1.1.1.1 37 0 0 34 0 0 48 0 0 + dcd B.2.2.3.1 36 0 0 40 0 0 39 0 0 + dcd A.1.1.1.2 36 0 0 36 0 0 38 0 0 + dcd B.2.1.2.1 37 37 0 33 33 0 39 39 0 + dcd D.1.1.1.1 37 0 37 31 0 31 39 0 39 + dcd D.1.1.4.2 36 36 0 31 31 0 38 38 0 + dcd B.1.1.1.1 35 0 35 37 0 37 33 0 33 + dcd C.2.1.2.1 26 0 0 36 0 0 42 0 0 + dcd C.1.1.1.3 32 32 0 34 34 0 33 33 0 + diff --git a/tests/testthat/_snaps/table_aet05.md b/tests/testthat/_snaps/table_aet05.md new file mode 100644 index 0000000000..0542d0219e --- /dev/null +++ b/tests/testthat/_snaps/table_aet05.md @@ -0,0 +1,26 @@ +# AET05 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————————————————————————————————————— + Total patient-years at risk 162.4 103.8 172.6 + Number of adverse events observed 78 104 67 + AE rate per 100 patient-years 48.03 100.15 38.82 + 95% CI (37.37, 58.69) (80.90, 119.40) (29.53, 48.12) + +# AET05 variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————————————————————————————————————— + Total patient-years at risk 162.4 103.8 172.6 + Number of adverse events observed 78 104 67 + AE rate per 100 patient-years 48.03 100.15 38.82 + 95% CI (37.97, 59.94) (81.83, 121.35) (30.09, 49.30) + diff --git a/tests/testthat/_snaps/table_aet06.md b/tests/testthat/_snaps/table_aet06.md new file mode 100644 index 0000000000..70e166b26c --- /dev/null +++ b/tests/testthat/_snaps/table_aet06.md @@ -0,0 +1,156 @@ +# AET06 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + F M F M F M + (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 77 (93.9%) 46 (88.5%) 65 (92.9%) 55 (88.7%) + Overall total number of events 377 232 419 203 378 325 + cl A.1 + Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%) + Total number of events 85 47 93 37 86 74 + dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%) + dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%) + cl B.1 + Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%) + Total number of events 33 23 36 24 35 27 + dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%) + cl B.2 + Total number of patients with at least one adverse event 46 (58.2%) 33 (60%) 45 (54.9%) 29 (55.8%) 44 (62.9%) 41 (66.1%) + Total number of events 81 48 86 52 64 79 + dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%) + dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%) + cl C.1 + Total number of patients with at least one adverse event 30 (38%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%) + Total number of events 39 16 52 11 44 20 + dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%) + cl C.2 + Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%) + Total number of events 32 16 39 14 33 32 + dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%) + cl D.1 + Total number of patients with at least one adverse event 45 (57%) 34 (61.8%) 40 (48.8%) 27 (51.9%) 41 (58.6%) 39 (62.9%) + Total number of events 72 55 64 42 73 62 + dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%) + dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%) + cl D.2 + Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%) + Total number of events 35 27 49 23 43 31 + dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%) + +# AET06 variant 3 is produced correctly + + Code + res + Output + Body System or Organ Class A: Drug X B: Placebo C: Combination + Dictionary-Derived Term <18.5 18.5 - 24.9 25 - 29.9 >30 <18.5 18.5 - 24.9 25 - 29.9 >30 <18.5 18.5 - 24.9 25 - 29.9 >30 + (N=44) (N=17) (N=11) (N=62) (N=37) (N=18) (N=10) (N=69) (N=28) (N=20) (N=18) (N=66) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 41 (93.2%) 14 (82.4%) 11 (100%) 56 (90.3%) 35 (94.6%) 16 (88.9%) 9 (90%) 63 (91.3%) 25 (89.3%) 19 (95%) 15 (83.3%) 61 (92.4%) + Overall total number of events 186 80 66 277 174 89 47 312 137 129 100 337 + cl A.1 + Total number of patients with at least one adverse event 23 (52.3%) 12 (70.6%) 7 (63.6%) 36 (58.1%) 19 (51.4%) 10 (55.6%) 6 (60%) 40 (58%) 16 (57.1%) 13 (65%) 14 (77.8%) 46 (69.7%) + Total number of events 38 22 13 59 35 22 6 67 30 23 30 77 + dcd A.1.1.1.1 14 (31.8%) 7 (41.2%) 3 (27.3%) 26 (41.9%) 12 (32.4%) 6 (33.3%) 4 (40.0%) 23 (33.3%) 12 (42.9%) 7 (35.0%) 13 (72.2%) 31 (47.0%) + dcd A.1.1.1.2 15 (34.1%) 8 (47.1%) 5 (45.5%) 20 (32.3%) 12 (32.4%) 8 (44.4%) 2 (20.0%) 26 (37.7%) 9 (32.1%) 7 (35.0%) 7 (38.9%) 27 (40.9%) + cl B.2 + Total number of patients with at least one adverse event 23 (52.3%) 10 (58.8%) 8 (72.7%) 38 (61.3%) 21 (56.8%) 8 (44.4%) 7 (70%) 38 (55.1%) 16 (57.1%) 16 (80%) 12 (66.7%) 41 (62.1%) + Total number of events 37 19 12 61 41 18 12 67 28 28 18 69 + dcd B.2.2.3.1 13 (29.5%) 7 (41.2%) 6 (54.5%) 22 (35.5%) 14 (37.8%) 7 (38.9%) 6 (60.0%) 27 (39.1%) 7 (25.0%) 13 (65.0%) 5 (27.8%) 26 (39.4%) + dcd B.2.1.2.1 14 (31.8%) 8 (47.1%) 4 (36.4%) 23 (37.1%) 14 (37.8%) 6 (33.3%) 4 (40.0%) 20 (29.0%) 13 (46.4%) 8 (40.0%) 8 (44.4%) 23 (34.8%) + cl D.1 + Total number of patients with at least one adverse event 24 (54.5%) 9 (52.9%) 8 (72.7%) 38 (61.3%) 18 (48.6%) 5 (27.8%) 7 (70%) 37 (53.6%) 15 (53.6%) 12 (60%) 11 (61.1%) 42 (63.6%) + Total number of events 38 11 17 61 30 11 14 51 30 23 16 66 + dcd D.1.1.1.1 13 (29.5%) 7 (41.2%) 7 (63.6%) 23 (37.1%) 13 (35.1%) 3 (16.7%) 4 (40.0%) 22 (31.9%) 12 (42.9%) 6 (30.0%) 8 (44.4%) 25 (37.9%) + dcd D.1.1.4.2 16 (36.4%) 4 (23.5%) 6 (54.5%) 22 (35.5%) 10 (27.0%) 4 (22.2%) 5 (50.0%) 23 (33.3%) 10 (35.7%) 9 (45.0%) 6 (33.3%) 25 (37.9%) + cl D.2 + Total number of patients with at least one adverse event 14 (31.8%) 7 (41.2%) 5 (45.5%) 21 (33.9%) 14 (37.8%) 10 (55.6%) 4 (40%) 30 (43.5%) 13 (46.4%) 10 (50%) 7 (38.9%) 27 (40.9%) + Total number of events 20 7 10 25 17 14 5 36 18 15 10 31 + dcd D.2.1.5.3 14 (31.8%) 7 (41.2%) 5 (45.5%) 21 (33.9%) 14 (37.8%) 10 (55.6%) 4 (40.0%) 30 (43.5%) 13 (46.4%) 10 (50.0%) 7 (38.9%) 27 (40.9%) + cl B.1 + Total number of patients with at least one adverse event 17 (38.6%) 5 (29.4%) 7 (63.6%) 18 (29%) 14 (37.8%) 8 (44.4%) 4 (40%) 23 (33.3%) 7 (25%) 10 (50%) 7 (38.9%) 19 (28.8%) + Total number of events 22 5 7 22 16 11 4 29 11 12 8 31 + dcd B.1.1.1.1 17 (38.6%) 5 (29.4%) 7 (63.6%) 18 (29.0%) 14 (37.8%) 8 (44.4%) 4 (40.0%) 23 (33.3%) 7 (25.0%) 10 (50.0%) 7 (38.9%) 19 (28.8%) + cl C.2 + Total number of patients with at least one adverse event 14 (31.8%) 4 (23.5%) 2 (18.2%) 15 (24.2%) 15 (40.5%) 5 (27.8%) 4 (40%) 24 (34.8%) 10 (35.7%) 13 (65%) 8 (44.4%) 24 (36.4%) + Total number of events 17 9 3 19 15 6 5 27 12 16 9 28 + dcd C.2.1.2.1 14 (31.8%) 4 (23.5%) 2 (18.2%) 15 (24.2%) 15 (40.5%) 5 (27.8%) 4 (40.0%) 24 (34.8%) 10 (35.7%) 13 (65.0%) 8 (44.4%) 24 (36.4%) + cl C.1 + Total number of patients with at least one adverse event 11 (25%) 4 (23.5%) 4 (36.4%) 24 (38.7%) 13 (35.1%) 6 (33.3%) 1 (10%) 26 (37.7%) 6 (21.4%) 7 (35%) 6 (33.3%) 24 (36.4%) + Total number of events 14 7 4 30 20 7 1 35 8 12 9 35 + dcd C.1.1.1.3 11 (25.0%) 4 (23.5%) 4 (36.4%) 24 (38.7%) 13 (35.1%) 6 (33.3%) 1 (10.0%) 26 (37.7%) 6 (21.4%) 7 (35.0%) 6 (33.3%) 24 (36.4%) + +# AET06 variant 5 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + F M F M F M + (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 77 (93.9%) 46 (88.5%) 65 (92.9%) 55 (88.7%) + Overall total number of events 377 232 419 203 378 325 + cl A.1 + Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%) + Total number of events 85 47 93 37 86 74 + hlt A.1.1.1 + Total number of patients with at least one adverse event 53 (67.1%) 25 (45.5%) 51 (62.2%) 24 (46.2%) 43 (61.4%) 46 (74.2%) + Total number of events 85 47 93 37 86 74 + dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%) + dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%) + cl B.1 + Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%) + Total number of events 33 23 36 24 35 27 + hlt B.1.1.1 + Total number of patients with at least one adverse event 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%) + Total number of events 33 23 36 24 35 27 + dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%) + cl B.2 + Total number of patients with at least one adverse event 46 (58.2%) 33 (60%) 45 (54.9%) 29 (55.8%) 44 (62.9%) 41 (66.1%) + Total number of events 81 48 86 52 64 79 + hlt B.2.1.2 + Total number of patients with at least one adverse event 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%) + Total number of events 41 24 43 19 27 39 + dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%) + hlt B.2.2.3 + Total number of patients with at least one adverse event 30 (38%) 18 (32.7%) 32 (39%) 22 (42.3%) 26 (37.1%) 25 (40.3%) + Total number of events 40 24 43 33 37 40 + dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%) + cl C.1 + Total number of patients with at least one adverse event 30 (38%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%) + Total number of events 39 16 52 11 44 20 + hlt C.1.1.1 + Total number of patients with at least one adverse event 30 (38%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%) + Total number of events 39 16 52 11 44 20 + dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%) + cl C.2 + Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%) + Total number of events 32 16 39 14 33 32 + hlt C.2.1.2 + Total number of patients with at least one adverse event 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%) + Total number of events 32 16 39 14 33 32 + dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%) + cl D.1 + Total number of patients with at least one adverse event 45 (57%) 34 (61.8%) 40 (48.8%) 27 (51.9%) 41 (58.6%) 39 (62.9%) + Total number of events 72 55 64 42 73 62 + hlt D.1.1.1 + Total number of patients with at least one adverse event 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25%) 27 (38.6%) 24 (38.7%) + Total number of events 32 29 36 15 39 32 + dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%) + hlt D.1.1.4 + Total number of patients with at least one adverse event 30 (38%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%) + Total number of events 40 26 28 27 34 30 + dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%) + cl D.2 + Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%) + Total number of events 35 27 49 23 43 31 + hlt D.2.1.5 + Total number of patients with at least one adverse event 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%) + Total number of events 35 27 49 23 43 31 + dcd D.2.1.5.3 26 (32.9%) 21 (38.2%) 40 (48.8%) 18 (34.6%) 34 (48.6%) 23 (37.1%) + diff --git a/tests/testthat/_snaps/table_aet06_smq.md b/tests/testthat/_snaps/table_aet06_smq.md new file mode 100644 index 0000000000..6ae2ebcd9f --- /dev/null +++ b/tests/testthat/_snaps/table_aet06_smq.md @@ -0,0 +1,68 @@ +# AET06_SMQ variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + F M F M F M + (N=79) (N=55) (N=82) (N=52) (N=70) (N=62) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 72 (91.1%) 50 (90.9%) 74 (90.2%) 45 (86.5%) 63 (90%) 55 (88.7%) + SMQ 1 (broad) + Total number of patients with at least one adverse event 69 (87.3%) 46 (83.6%) 70 (85.4%) 42 (80.8%) 62 (88.6%) 54 (87.1%) + Total number of events 229 141 245 114 238 183 + dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%) + dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%) + dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%) + dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%) + dcd B.1.1.1.1 28 (35.4%) 19 (34.5%) 33 (40.2%) 16 (30.8%) 24 (34.3%) 19 (30.6%) + dcd C.1.1.1.3 30 (38.0%) 13 (23.6%) 36 (43.9%) 10 (19.2%) 27 (38.6%) 16 (25.8%) + SMQ 1 (narrow) + Total number of patients with at least one adverse event 64 (81%) 36 (65.5%) 63 (76.8%) 36 (69.2%) 53 (75.7%) 54 (87.1%) + Total number of events 157 102 157 79 159 136 + dcd A.1.1.1.1 34 (43.0%) 16 (29.1%) 31 (37.8%) 14 (26.9%) 33 (47.1%) 30 (48.4%) + dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%) + dcd D.1.1.1.1 25 (31.6%) 25 (45.5%) 29 (35.4%) 13 (25.0%) 27 (38.6%) 24 (38.7%) + dcd D.1.1.4.2 30 (38.0%) 18 (32.7%) 22 (26.8%) 20 (38.5%) 27 (38.6%) 23 (37.1%) + AESI + Total number of patients with at least one adverse event 59 (74.7%) 38 (69.1%) 66 (80.5%) 37 (71.2%) 54 (77.1%) 53 (85.5%) + Total number of events 155 90 176 83 138 142 + dcd B.2.2.3.1 30 (38.0%) 18 (32.7%) 32 (39.0%) 22 (42.3%) 26 (37.1%) 25 (40.3%) + dcd A.1.1.1.2 32 (40.5%) 16 (29.1%) 33 (40.2%) 15 (28.8%) 24 (34.3%) 26 (41.9%) + dcd B.2.1.2.1 29 (36.7%) 20 (36.4%) 30 (36.6%) 14 (26.9%) 22 (31.4%) 30 (48.4%) + dcd C.2.1.2.1 23 (29.1%) 12 (21.8%) 36 (43.9%) 12 (23.1%) 30 (42.9%) 25 (40.3%) + +# AET06_SMQ variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + >= 65 < 65 >= 65 < 65 >= 65 < 65 + (N=0) (N=134) (N=0) (N=134) (N=1) (N=131) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event 0 122 (91%) 0 119 (88.8%) 1 (100%) 117 (89.3%) + SMQ 1 (broad) + Total number of patients with at least one adverse event 0 115 (85.8%) 0 112 (83.6%) 1 (100%) 115 (87.8%) + Total number of events 0 370 0 359 2 419 + dcd A.1.1.1.1 0 50 (37.3%) 0 45 (33.6%) 0 63 (48.1%) + dcd A.1.1.1.2 0 48 (35.8%) 0 48 (35.8%) 0 50 (38.2%) + dcd D.1.1.1.1 0 50 (37.3%) 0 42 (31.3%) 0 51 (38.9%) + dcd D.1.1.4.2 0 48 (35.8%) 0 42 (31.3%) 1 (100%) 49 (37.4%) + dcd B.1.1.1.1 0 47 (35.1%) 0 49 (36.6%) 1 (100%) 42 (32.1%) + dcd C.1.1.1.3 0 43 (32.1%) 0 46 (34.3%) 0 43 (32.8%) + SMQ 1 (narrow) + Total number of patients with at least one adverse event 0 100 (74.6%) 0 99 (73.9%) 1 (100%) 106 (80.9%) + Total number of events 0 259 0 236 1 294 + dcd A.1.1.1.1 0 50 (37.3%) 0 45 (33.6%) 0 63 (48.1%) + dcd A.1.1.1.2 0 48 (35.8%) 0 48 (35.8%) 0 50 (38.2%) + dcd D.1.1.1.1 0 50 (37.3%) 0 42 (31.3%) 0 51 (38.9%) + dcd D.1.1.4.2 0 48 (35.8%) 0 42 (31.3%) 1 (100%) 49 (37.4%) + AESI + Total number of patients with at least one adverse event 0 97 (72.4%) 0 103 (76.9%) 1 (100%) 106 (80.9%) + Total number of events 0 245 0 259 1 279 + dcd B.2.2.3.1 0 48 (35.8%) 0 54 (40.3%) 0 51 (38.9%) + dcd A.1.1.1.2 0 48 (35.8%) 0 48 (35.8%) 0 50 (38.2%) + dcd B.2.1.2.1 0 49 (36.6%) 0 44 (32.8%) 1 (100%) 51 (38.9%) + dcd C.2.1.2.1 0 35 (26.1%) 0 48 (35.8%) 0 55 (42.0%) + diff --git a/tests/testthat/_snaps/table_aet07.md b/tests/testthat/_snaps/table_aet07.md new file mode 100644 index 0000000000..9a0e431605 --- /dev/null +++ b/tests/testthat/_snaps/table_aet07.md @@ -0,0 +1,24 @@ +# AET07 variant 1 is produced correctly + + Code + res + Output + B: Placebo C: Combination + (N=134) (N=132) + ———————————————————————————————————————————————————— + Total number of deaths 70 (52.2%) 75 (56.8%) + cl D.1 / dcd D.1.1.1.1 42 (31.3%) 51 (38.6%) + cl B.1 / dcd B.1.1.1.1 49 (36.6%) 43 (32.6%) + +# AET07 variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + Total number of deaths 0 70 (52.2%) 75 (56.8%) + cl D.1 / dcd D.1.1.1.1 0 42 (31.3%) 51 (38.6%) + cl B.1 / dcd B.1.1.1.1 0 49 (36.6%) 43 (32.6%) + diff --git a/tests/testthat/_snaps/table_aet09.md b/tests/testthat/_snaps/table_aet09.md new file mode 100644 index 0000000000..03ae2f0006 --- /dev/null +++ b/tests/testthat/_snaps/table_aet09.md @@ -0,0 +1,77 @@ +# AET09 variant 1 is produced correctly, AE related to study drug + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event related to study drug 105 (78.4%) 108 (80.6%) 109 (82.6%) 322 (80.5%) + Overall total number of events related to study drug 282 299 336 917 + cl D.2 + Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + Total number of events related to study drug 62 72 74 208 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + cl D.1 + Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) + Total number of events related to study drug 61 51 71 183 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) + cl B.1 + Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + Total number of events related to study drug 56 60 62 178 + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + cl C.2 + Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + Total number of events related to study drug 48 53 65 166 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + cl C.1 + Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33%) + Total number of events related to study drug 55 63 64 182 + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) + +# AET09 variant 2 is produced correctly, AE related to study drug (including high-level terms) + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event related to study drug 105 (78.4%) 108 (80.6%) 109 (82.6%) + Overall total number of events related to study drug 282 299 336 + cl D.2 + Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) + Total number of events related to study drug 62 72 74 + hlt D.2.1.5 + Total number of patients with at least one adverse event related to study drug 47 (35.1%) 58 (43.3%) 57 (43.2%) + Total number of events related to study drug 62 72 74 + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) + cl D.1 + Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) + Total number of events related to study drug 61 51 71 + hlt D.1.1.1 + Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) + Total number of events related to study drug 61 51 71 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + cl B.1 + Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) + Total number of events related to study drug 56 60 62 + hlt B.1.1.1 + Total number of patients with at least one adverse event related to study drug 47 (35.1%) 49 (36.6%) 43 (32.6%) + Total number of events related to study drug 56 60 62 + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) + cl C.2 + Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) + Total number of events related to study drug 48 53 65 + hlt C.2.1.2 + Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) + Total number of events related to study drug 48 53 65 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl C.1 + Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) + Total number of events related to study drug 55 63 64 + hlt C.1.1.1 + Total number of patients with at least one adverse event related to study drug 43 (32.1%) 46 (34.3%) 43 (32.6%) + Total number of events related to study drug 55 63 64 + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + diff --git a/tests/testthat/_snaps/table_aet09_smq.md b/tests/testthat/_snaps/table_aet09_smq.md new file mode 100644 index 0000000000..78f1af746e --- /dev/null +++ b/tests/testthat/_snaps/table_aet09_smq.md @@ -0,0 +1,40 @@ +# AET09 variant 1 (AEs related to study drug by SMQ) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event related to study drug 91 (67.9%) 90 (67.2%) 93 (70.5%) + SMQ1 + Total number of patients with at least one adverse event related to study drug 91 (67.9%) 90 (67.2%) 93 (70.5%) + Total number of events related to study drug 172 174 197 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + +# AET09 variant 2 (AEs related to study drug by SMQ with customized queries) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one adverse event related to study drug 99 (73.9%) 98 (73.1%) 102 (77.3%) + SMQ1 + Total number of patients with at least one adverse event related to study drug 91 (67.9%) 90 (67.2%) 93 (70.5%) + Total number of events related to study drug 172 174 197 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + dcd B.1.1.1.1 47 (35.1%) 49 (36.6%) 43 (32.6%) + dcd C.1.1.1.3 43 (32.1%) 46 (34.3%) 43 (32.6%) + SMQ2 + Total number of patients with at least one adverse event related to study drug 50 (37.3%) 42 (31.3%) 51 (38.6%) + Total number of events related to study drug 61 51 71 + dcd D.1.1.1.1 50 (37.3%) 42 (31.3%) 51 (38.6%) + SMQ3 + Total number of patients with at least one adverse event related to study drug 35 (26.1%) 48 (35.8%) 55 (41.7%) + Total number of events related to study drug 48 53 65 + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) + diff --git a/tests/testthat/_snaps/table_aet10.md b/tests/testthat/_snaps/table_aet10.md new file mode 100644 index 0000000000..28ebbe29c2 --- /dev/null +++ b/tests/testthat/_snaps/table_aet10.md @@ -0,0 +1,13 @@ +# AET10 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————— + dcd D.2.1.5.3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + dcd A.1.1.1.1 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) + dcd B.2.2.3.1 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) + dcd C.2.1.2.1 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + diff --git a/tests/testthat/_snaps/table_aovt01.md b/tests/testthat/_snaps/table_aovt01.md new file mode 100644 index 0000000000..90268ad9cb --- /dev/null +++ b/tests/testthat/_snaps/table_aovt01.md @@ -0,0 +1,65 @@ +# AOVT01 variant with single endpoint is produced correctly + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————— + Unadjusted comparison + n 68 73 62 + Mean 3.68 5.07 3.09 + Difference in Means 1.38 -0.59 + 95% CI (-2.76, 5.53) (-4.91, 3.73) + p-value 0.5113 0.7873 + Adjusted comparison (covariates BASE and STRATA1) + n 68 73 62 + Adjusted Mean 4.06 3.57 3.34 + Difference in Adjusted Means -0.49 -0.72 + 95% CI (-3.28, 2.29) (-3.57, 2.12) + p-value 0.7277 0.6165 + +# AOVT01 variant with multiple endpoints is produced correctly + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————— + BFIALL + Adjusted mean + n 134 134 132 + Adjusted Mean 4.47 6.33 4.02 + Difference in Adjusted Means 1.85 -0.46 + 95% CI (-0.14, 3.85) (-2.45, 1.54) + p-value 0.0679 0.6539 + FATIGI + Adjusted mean + n 134 134 132 + Adjusted Mean 5.42 4.83 4.56 + Difference in Adjusted Means -0.59 -0.86 + 95% CI (-2.58, 1.41) (-2.87, 1.15) + p-value 0.5644 0.4026 + FKSI-FWB + Adjusted mean + n 134 134 132 + Adjusted Mean 4.29 3.51 3.06 + Difference in Adjusted Means -0.79 -1.24 + 95% CI (-2.71, 1.14) (-3.17, 0.69) + p-value 0.4221 0.2088 + FKSI-TSE + Adjusted mean + n 134 134 132 + Adjusted Mean 4.70 3.84 4.45 + Difference in Adjusted Means -0.86 -0.25 + 95% CI (-2.80, 1.09) (-2.20, 1.70) + p-value 0.3858 0.8007 + FKSIALL + Adjusted mean + n 134 134 132 + Adjusted Mean 5.03 5.82 6.44 + Difference in Adjusted Means 0.79 1.42 + 95% CI (-1.17, 2.76) (-0.56, 3.39) + p-value 0.4288 0.1591 + diff --git a/tests/testthat/_snaps/table_cmt01.md b/tests/testthat/_snaps/table_cmt01.md new file mode 100644 index 0000000000..23c446152f --- /dev/null +++ b/tests/testthat/_snaps/table_cmt01.md @@ -0,0 +1,95 @@ +# CMT01 default variant (Concomitant medications) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) + Total number of treatments 832 857 925 2614 + medcl A + Total number of patients with at least one treatment 75 (56%) 79 (59%) 81 (61.4%) 235 (58.8%) + Total number of treatments 192 203 207 602 + medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) + medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) + medcl B + Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) 245 (61.3%) + Total number of treatments 291 301 328 920 + medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) + medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) + medcl C + Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) 255 (63.7%) + Total number of treatments 349 353 390 1092 + medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) + medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) + +# CMT01 variant 1 (prior medications) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one treatment 89 (66.4%) 95 (70.9%) 106 (80.3%) 290 (72.5%) + Total number of treatments 322 354 395 1071 + medcl A + Total number of patients with at least one treatment 54 (40.3%) 49 (36.6%) 69 (52.3%) 172 (43%) + Total number of treatments 71 70 99 240 + medname A_1/3 54 (40.3%) 49 (36.6%) 69 (52.3%) 172 (43.0%) + medcl B + Total number of patients with at least one treatment 76 (56.7%) 80 (59.7%) 81 (61.4%) 237 (59.2%) + Total number of treatments 251 284 296 831 + medname B_2/4 52 (38.8%) 55 (41.0%) 56 (42.4%) 163 (40.8%) + medname B_3/4 47 (35.1%) 47 (35.1%) 52 (39.4%) 146 (36.5%) + +# CMT01 variant 3 (Concomitant medications) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one treatment 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) + Total number of treatments 832 857 925 2614 + medcl A + Total number of patients with at least one treatment 75 (56%) 79 (59%) 81 (61.4%) 235 (58.8%) + medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) + medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) + medcl B + Total number of patients with at least one treatment 83 (61.9%) 74 (55.2%) 88 (66.7%) 245 (61.3%) + medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) + medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) + medcl C + Total number of patients with at least one treatment 82 (61.2%) 84 (62.7%) 89 (67.4%) 255 (63.7%) + medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) + medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) + +# CMT01 variant 4 (Concomitant medications) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one treatment (%) 117 (87.3%) 116 (86.6%) 116 (87.9%) 349 (87.2%) + Total number of treatments 832 857 925 2614 + medcl C + Total number of patients with at least one treatment (%) 82 (61.2%) 84 (62.7%) 89 (67.4%) 255 (63.7%) + Total number of treatments 349 353 390 1092 + medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) + medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) + medcl B + Total number of patients with at least one treatment (%) 83 (61.9%) 74 (55.2%) 88 (66.7%) 245 (61.3%) + Total number of treatments 291 301 328 920 + medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) + medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) + medcl A + Total number of patients with at least one treatment (%) 75 (56%) 79 (59%) 81 (61.4%) 235 (58.8%) + Total number of treatments 192 203 207 602 + medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) + medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) + diff --git a/tests/testthat/_snaps/table_cmt02_pt.md b/tests/testthat/_snaps/table_cmt02_pt.md new file mode 100644 index 0000000000..b60047ec86 --- /dev/null +++ b/tests/testthat/_snaps/table_cmt02_pt.md @@ -0,0 +1,20 @@ +# CMT02_PT default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one event 122 (91%) 123 (91.8%) 120 (90.9%) 365 (91.2%) + Total number of events 609 622 703 1934 + medname A_1/3 54 (40.3%) 49 (36.6%) 69 (52.3%) 172 (43.0%) + medname C_2/2 52 (38.8%) 58 (43.3%) 60 (45.5%) 170 (42.5%) + medname B_1/4 52 (38.8%) 57 (42.5%) 59 (44.7%) 168 (42.0%) + medname B_2/4 52 (38.8%) 55 (41.0%) 56 (42.4%) 163 (40.8%) + medname A_2/3 53 (39.6%) 50 (37.3%) 56 (42.4%) 159 (39.8%) + medname C_1/2 51 (38.1%) 50 (37.3%) 56 (42.4%) 157 (39.2%) + medname B_4/4 50 (37.3%) 45 (33.6%) 55 (41.7%) 150 (37.5%) + medname A_3/3 45 (33.6%) 54 (40.3%) 48 (36.4%) 147 (36.8%) + medname B_3/4 47 (35.1%) 47 (35.1%) 52 (39.4%) 146 (36.5%) + diff --git a/tests/testthat/_snaps/table_coxt01.md b/tests/testthat/_snaps/table_coxt01.md new file mode 100644 index 0000000000..00b01fa7dd --- /dev/null +++ b/tests/testthat/_snaps/table_coxt01.md @@ -0,0 +1,78 @@ +# 1. Cox Regression + + Code + res + Output + n Hazard Ratio 95% CI p-value + ———————————————————————————————————————————————————————————————————————— + Treatment: + ARM A vs control (ARM B) 247 0.70 (0.51, 0.96) 0.0293 + Covariate: + Sex 247 0.71 (0.52, 0.98) 0.0370 + Race 247 0.70 (0.51, 0.97) 0.0318 + Age 247 0.70 (0.51, 0.97) 0.0321 + +# 2. Cox Regression (with Interaction Term) + + Code + res + Output + n Hazard Ratio 95% CI p-value Interaction p-value + ————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment: + ARM A vs control (ARM B) 247 0.70 (0.51, 0.96) 0.0293 + Covariate: + Sex 247 0.4635 + F 0.64 (0.42, 0.98) + M 0.82 (0.50, 1.35) + Race 247 0.9197 + ASIAN 0.75 (0.48, 1.16) + BLACK OR AFRICAN AMERICAN 0.66 (0.34, 1.28) + WHITE 0.65 (0.33, 1.27) + Age 247 0.8626 + 34 0.70 (0.51, 0.97) + +# 3. Cox Regression (specifying covariates) + + Code + res + Output + n Hazard Ratio 95% CI p-value Interaction p-value + ————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment: + ARM A vs control (ARM B) 247 0.70 (0.51, 0.96) 0.0293 + Covariate: + Sex 247 0.4635 + F 0.64 (0.42, 0.98) + M 0.82 (0.50, 1.35) + Race 247 0.9197 + ASIAN 0.75 (0.48, 1.16) + BLACK OR AFRICAN AMERICAN 0.66 (0.34, 1.28) + WHITE 0.65 (0.33, 1.27) + Age 247 0.8626 + 30 0.69 (0.48, 1.00) + 40 0.72 (0.48, 1.08) + 50 0.75 (0.35, 1.61) + +# 4. Cox Regression (setting strata, ties, and alpha level) + + Code + res + Output + n Hazard Ratio 90% CI p-value Interaction p-value + ————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment: + ARM A vs control (ARM B) 247 0.70 (0.53, 0.92) 0.0293 + Covariate: + Sex 247 0.4635 + F 0.64 (0.42, 0.98) + M 0.82 (0.50, 1.35) + Race 247 0.9197 + ASIAN 0.75 (0.48, 1.16) + BLACK OR AFRICAN AMERICAN 0.66 (0.34, 1.28) + WHITE 0.65 (0.33, 1.27) + Age 247 0.8626 + 30 0.69 (0.51, 0.94) + 40 0.72 (0.51, 1.02) + 50 0.75 (0.39, 1.42) + diff --git a/tests/testthat/_snaps/table_coxt02.md b/tests/testthat/_snaps/table_coxt02.md new file mode 100644 index 0000000000..e9df4b9f78 --- /dev/null +++ b/tests/testthat/_snaps/table_coxt02.md @@ -0,0 +1,28 @@ +# COXT02 default variant 1 is produced correctly + + Code + res + Output + Hazard Ratio 95% CI p-value + ————————————————————————————————————————————————————————————————— + ARMCD (reference = ARM B) <0.0001 + ARM A 0.72 (0.52, 0.99) 0.0417 + ARM C 1.93 (1.44, 2.59) <0.0001 + Sex (reference = F) + M 1.17 (0.91, 1.51) 0.2142 + Age 1.01 (0.99, 1.02) 0.4785 + +# COXT02 variant 5 is produced correctly + + Code + res + Output + Hazard Ratio 90% CI + ——————————————————————————————————————————————————————— + ARMCD (reference = ARM B) + ARM A 0.72 (0.55, 0.95) + ARM C 1.96 (1.52, 2.51) + Sex (reference = F) + M 1.21 (0.98, 1.49) + Age 1.01 (0.99, 1.02) + diff --git a/tests/testthat/_snaps/table_disclosures.md b/tests/testthat/_snaps/table_disclosures.md new file mode 100644 index 0000000000..ade24ee430 --- /dev/null +++ b/tests/testthat/_snaps/table_disclosures.md @@ -0,0 +1,124 @@ +# Patient Disposition table is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + —————————————————————————————————————————————————————————————————————————————————————————————————— + Started Study 134 (100.00%) 134 (100.00%) 132 (100.00%) 400 (100.00%) + Completed Study 68 (50.75%) 66 (49.25%) 73 (55.30%) 207 (51.75%) + Discontinued Study 42 (31.34%) 40 (29.85%) 38 (28.79%) 120 (30.00%) + ADVERSE EVENT 3 (2.24%) 6 (4.48%) 5 (3.79%) 14 (3.50%) + DEATH 25 (18.66%) 23 (17.16%) 22 (16.67%) 70 (17.50%) + LACK OF EFFICACY 2 (1.49%) 2 (1.49%) 3 (2.27%) 7 (1.75%) + PHYSICIAN DECISION 2 (1.49%) 3 (2.24%) 2 (1.52%) 7 (1.75%) + PROTOCOL VIOLATION 5 (3.73%) 3 (2.24%) 4 (3.03%) 12 (3.00%) + WITHDRAWAL BY PARENT/GUARDIAN 4 (2.99%) 2 (1.49%) 1 (0.76%) 7 (1.75%) + WITHDRAWAL BY SUBJECT 1 (0.75%) 1 (0.75%) 1 (0.76%) 3 (0.75%) + +# Demographic table is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Age (yr) + n 134 134 132 400 + Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) + Median 33.0 35.0 35.0 34.0 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 + Age group (yr) + n 134 134 132 400 + < 65 yrs 134 (100%) 134 (100%) 131 (99.2%) 399 (99.8%) + >= 65 yrs 0 0 1 (0.8%) 1 (0.2%) + Sex + n 134 134 132 400 + F 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) + M 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) + Race + n 134 134 132 400 + ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) 208 (52%) + BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) 91 (22.8%) + WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) 74 (18.5%) + AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) 25 (6.2%) + MULTIPLE 0 1 (0.7%) 0 1 (0.2%) + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 1 (0.2%) + Ethnicity + n 134 134 132 400 + Ethnicity 1 50 (37.3%) 51 (38.1%) 46 (34.8%) 147 (36.8%) + Ethnicity 2 46 (34.3%) 38 (28.4%) 41 (31.1%) 125 (31.2%) + Unknown 38 (28.4%) 45 (33.6%) 45 (34.1%) 128 (32%) + +# Enrollment by Country Table is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————— + n 134 134 132 400 + CHN 74 (55.22%) 81 (60.45%) 64 (48.48%) 219 (54.75%) + USA 10 (7.46%) 13 (9.70%) 17 (12.88%) 40 (10.00%) + BRA 13 (9.70%) 7 (5.22%) 10 (7.58%) 30 (7.50%) + PAK 12 (8.96%) 9 (6.72%) 10 (7.58%) 31 (7.75%) + NGA 8 (5.97%) 7 (5.22%) 11 (8.33%) 26 (6.50%) + RUS 5 (3.73%) 8 (5.97%) 6 (4.55%) 19 (4.75%) + JPN 5 (3.73%) 4 (2.99%) 9 (6.82%) 18 (4.50%) + GBR 4 (2.99%) 3 (2.24%) 2 (1.52%) 9 (2.25%) + CAN 3 (2.24%) 2 (1.49%) 3 (2.27%) 8 (2.00%) + CHE 0 (0.00%) 0 (0.00%) 0 (0.00%) 0 (0.00%) + +# Death table is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + —————————————————————————————————————————————————————————————————————————————————— + Total Number of Deaths 76 (62.30%) 70 (56.91%) 75 (62.50%) 221 (60.55%) + +# Table of Serious Adverse Events is produced correctly (for one specific treatment arm) + + Code + res + Output + Patients (All) Events (All) Events (Related) Events (Fatal) Events (Fatal & Related) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one serious adverse event 104 + cl A.1 + dcd A.1.1.1.2 48 68 0 0 0 + cl B.1 + dcd B.1.1.1.1 47 56 56 56 56 + cl B.2 + dcd B.2.2.3.1 48 64 0 0 0 + cl D.1 + dcd D.1.1.1.1 50 61 61 61 61 + +# Table of Non-Serious Adverse Events is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Patients (All) Events (All) Patients (All) Events (All) Patients (All) Events (All) + (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one non-SAE and number of events 106 360 112 367 112 421 + cl A.1 + dcd A.1.1.1.1 50 64 45 62 63 88 + cl B.2 + dcd B.2.1.2.1 49 65 44 62 52 66 + cl C.1 + dcd C.1.1.1.3 43 55 46 63 43 64 + cl C.2 + dcd C.2.1.2.1 35 48 48 53 55 65 + cl D.1 + dcd D.1.1.4.2 48 66 42 55 50 64 + cl D.2 + dcd D.2.1.5.3 47 62 58 72 57 74 + diff --git a/tests/testthat/_snaps/table_dmt01.md b/tests/testthat/_snaps/table_dmt01.md new file mode 100644 index 0000000000..5c432609b5 --- /dev/null +++ b/tests/testthat/_snaps/table_dmt01.md @@ -0,0 +1,123 @@ +# DMT01 default and alternative variants are produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Age (yr) + n 134 134 132 400 + Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) + Median 33.0 35.0 35.0 34.0 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 + Age group (yr) + n 134 134 132 400 + 18-40 113 (84.3%) 103 (76.9%) 106 (80.3%) 322 (80.5%) + 41-64 21 (15.7%) 31 (23.1%) 25 (18.9%) 77 (19.2%) + >=65 0 0 1 (0.8%) 1 (0.2%) + Sex + n 134 134 132 400 + Female 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) + Male 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) + Race + n 134 134 132 400 + ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) 208 (52%) + BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) 91 (22.8%) + WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) 74 (18.5%) + AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) 25 (6.2%) + MULTIPLE 0 1 (0.7%) 0 1 (0.2%) + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 1 (0.2%) + OTHER 0 0 0 0 + UNKNOWN 0 0 0 0 + Weight (kg) at Baseline + n 134 134 132 400 + Mean (SD) 50.7 (7.9) 49.9 (8.3) 49.4 (7.5) 50.0 (7.9) + Median 49.8 50.7 49.6 50.1 + Min - Max 33.3 - 71.9 27.9 - 69.8 29.4 - 65.1 27.9 - 71.9 + Systolic Blood Pressure at Baseline + n 134 134 132 400 + Mean (SD) 49.4 (8.5) 50.2 (8.5) 48.5 (7.2) 49.4 (8.1) + Median 48.3 50.0 49.2 49.2 + Min - Max 24.3 - 71.1 24.4 - 71.1 26.2 - 63.4 24.3 - 71.1 + Diastolic Blood Pressure at Baseline + n 134 134 132 400 + Mean (SD) 48.6 (8.0) 50.4 (7.9) 51.1 (7.8) 50.0 (8.0) + Median 48.4 50.2 50.8 50.0 + Min - Max 27.7 - 64.6 21.7 - 67.5 29.7 - 71.4 21.7 - 71.4 + +--- + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ————————————————————————————————————————————————————————————————————————————————————————————————————————— + Female + Race + n 79 82 70 231 + ASIAN 41 (51.9%) 40 (48.8%) 39 (55.7%) 120 (51.9%) + BLACK OR AFRICAN AMERICAN 18 (22.8%) 16 (19.5%) 16 (22.9%) 50 (21.6%) + WHITE 17 (21.5%) 18 (22%) 11 (15.7%) 46 (19.9%) + AMERICAN INDIAN OR ALASKA NATIVE 3 (3.8%) 7 (8.5%) 4 (5.7%) 14 (6.1%) + MULTIPLE 0 0 0 0 + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (1.2%) 0 1 (0.4%) + OTHER 0 0 0 0 + UNKNOWN 0 0 0 0 + Weight (kg) at Baseline + n 79 82 70 231 + Mean (SD) 50.3 (7.0) 50.0 (7.8) 49.2 (7.5) 49.9 (7.4) + Median 50.1 50.7 49.6 50.3 + Min - Max 35.9 - 69.9 27.9 - 68.9 29.4 - 63.8 27.9 - 69.9 + Systolic Blood Pressure at Baseline + n 79 82 70 231 + Mean (SD) 49.7 (7.9) 49.6 (8.6) 48.1 (7.1) 49.1 (7.9) + Median 48.7 49.0 49.1 49.1 + Min - Max 25.4 - 71.1 24.4 - 68.8 26.2 - 63.4 24.4 - 71.1 + Diastolic Blood Pressure at Baseline + n 79 82 70 231 + Mean (SD) 48.4 (8.8) 50.5 (7.8) 51.5 (7.8) 50.1 (8.2) + Median 48.2 49.9 50.6 49.9 + Min - Max 27.7 - 64.6 35.1 - 67.5 29.7 - 67.8 27.7 - 67.8 + Male + Race + n 55 52 62 169 + ASIAN 27 (49.1%) 27 (51.9%) 34 (54.8%) 88 (52.1%) + BLACK OR AFRICAN AMERICAN 13 (23.6%) 12 (23.1%) 16 (25.8%) 41 (24.3%) + WHITE 10 (18.2%) 8 (15.4%) 10 (16.1%) 28 (16.6%) + AMERICAN INDIAN OR ALASKA NATIVE 5 (9.1%) 4 (7.7%) 2 (3.2%) 11 (6.5%) + MULTIPLE 0 1 (1.9%) 0 1 (0.6%) + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 0 0 0 + OTHER 0 0 0 0 + UNKNOWN 0 0 0 0 + Weight (kg) at Baseline + n 55 52 62 169 + Mean (SD) 51.3 (8.9) 49.7 (9.2) 49.6 (7.5) 50.2 (8.5) + Median 49.4 50.8 49.6 49.6 + Min - Max 33.3 - 71.9 30.5 - 69.8 35.5 - 65.1 30.5 - 71.9 + Systolic Blood Pressure at Baseline + n 55 52 62 169 + Mean (SD) 49.0 (9.3) 51.3 (8.4) 49.0 (7.3) 49.7 (8.4) + Median 47.9 51.2 50.3 50.1 + Min - Max 24.3 - 69.2 34.0 - 71.1 30.0 - 61.6 24.3 - 71.1 + Diastolic Blood Pressure at Baseline + n 55 52 62 169 + Mean (SD) 49.0 (6.7) 50.4 (8.2) 50.7 (7.8) 50.0 (7.6) + Median 48.5 50.4 50.9 50.1 + Min - Max 31.5 - 64.0 21.7 - 63.3 30.8 - 71.4 21.7 - 71.4 + Age (yr) + n 134 134 132 400 + Mean (SD) 33.8 (6.6) 35.4 (7.9) 35.4 (7.7) 34.9 (7.4) + Median 33.0 35.0 35.0 34.0 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 + Age group (yr) + n 134 134 132 400 + 18-40 113 (84.3%) 103 (76.9%) 106 (80.3%) 322 (80.5%) + 41-64 21 (15.7%) 31 (23.1%) 25 (18.9%) 77 (19.2%) + >=65 0 0 1 (0.8%) 1 (0.2%) + Sex + n 134 134 132 400 + Female 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) + Male 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) + diff --git a/tests/testthat/_snaps/table_dort01.md b/tests/testthat/_snaps/table_dort01.md new file mode 100644 index 0000000000..b210b0ab0f --- /dev/null +++ b/tests/testthat/_snaps/table_dort01.md @@ -0,0 +1,100 @@ +# DORT01 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————— + Responders 68 73 62 + Responders with subsequent event (%) 33 (48.5%) 51 (69.9%) 53 (85.5%) + Earliest contributing event + Death 14 20 25 + Disease Progression 19 31 28 + Responders without subsequent event (%) 35 (51.5%) 22 (30.1%) 9 (14.5%) + Duration of response (Months) + Median 23.8 11.1 6.6 + 95% CI (17.9, 39.6) (8.3, 14.6) (4.4, 9.2) + 25% and 75%-ile 9.3, 44.3 6.2, 20.5 3.0, 15.7 + Range (censored) 1.6 to 64.5 0.1 to 43.8 0.2 to 39.6 + Range (event) 0.3 to 44.3 0.6 to 61.9 0.2 to 53.8 + 12 Months duration + Patients remaining at risk 28 25 18 + Event Free Rate (%) 63.41 43.82 33.72 + 95% CI (50.48, 76.34) (31.28, 56.36) (21.28, 46.15) + +# DORT01 variant 2 (selecting sectons) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————— + Responders 68 73 62 + Responders with subsequent event (%) 33 (48.5%) 51 (69.9%) 53 (85.5%) + Earliest contributing event + Death 14 20 25 + Disease Progression 19 31 28 + Responders without subsequent event (%) 35 (51.5%) 22 (30.1%) 9 (14.5%) + Duration of response (Months) + Median 23.8 11.1 6.6 + 95% CI (17.9, 39.6) (8.3, 14.6) (4.4, 9.2) + 25% and 75%-ile 9.3, 44.3 6.2, 20.5 3.0, 15.7 + Range (censored) 1.6 to 64.5 0.1 to 43.8 0.2 to 39.6 + Range (event) 0.3 to 44.3 0.6 to 61.9 0.2 to 53.8 + Unstratified Analysis + p-value (log-rank) 0.0029 <0.0001 + Hazard Ratio 1.94 2.99 + 95% CI (1.24, 3.02) (1.92, 4.67) + +# DORT01 variant 3 (modifying conftype and alpha level) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————— + Responders 68 73 62 + Responders with subsequent event (%) 33 (48.5%) 51 (69.9%) 53 (85.5%) + Earliest contributing event + Death 14 20 25 + Disease Progression 19 31 28 + Responders without subsequent event (%) 35 (51.5%) 22 (30.1%) 9 (14.5%) + Duration of response (Months) + Median 23.8 11.1 6.6 + 90% CI (17.9, 30.2) (9.1, 14.0) (4.4, 8.0) + 25% and 75%-ile 9.3, 44.3 6.2, 20.5 3.0, 15.7 + Range (censored) 1.6 to 64.5 0.1 to 43.8 0.2 to 39.6 + Range (event) 0.3 to 44.3 0.6 to 61.9 0.2 to 53.8 + 12 Months duration + Patients remaining at risk 28 25 18 + Event Free Rate (%) 63.41 43.82 33.72 + 97.5% CI (48.63, 78.19) (29.48, 58.16) (19.49, 47.94) + +# DORT01 variant 4 (modifying time point for the “xx duration”) is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————— + Responders 68 73 62 + Responders with subsequent event (%) 33 (48.5%) 51 (69.9%) 53 (85.5%) + Earliest contributing event + Death 14 20 25 + Disease Progression 19 31 28 + Responders without subsequent event (%) 35 (51.5%) 22 (30.1%) 9 (14.5%) + Duration of response (Months) + Median 23.8 11.1 6.6 + 95% CI (17.9, 39.6) (8.3, 14.6) (4.4, 9.2) + 25% and 75%-ile 9.3, 44.3 6.2, 20.5 3.0, 15.7 + Range (censored) 1.6 to 64.5 0.1 to 43.8 0.2 to 39.6 + Range (event) 0.3 to 44.3 0.6 to 61.9 0.2 to 53.8 + 6 Months duration + Patients remaining at risk 51 48 28 + Event Free Rate (%) 83.63 76.14 50.57 + 95% CI (74.78, 92.48) (65.92, 86.35) (37.68, 63.46) + diff --git a/tests/testthat/_snaps/table_dst01.md b/tests/testthat/_snaps/table_dst01.md new file mode 100644 index 0000000000..8fcc892ef2 --- /dev/null +++ b/tests/testthat/_snaps/table_dst01.md @@ -0,0 +1,51 @@ +# DST01 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————— + Completed Study 65 (48.51%) 67 (50.00%) 69 (52.27%) 201 (50.25%) + Discontinued Study 15 (11.2%) 28 (20.9%) 24 (18.2%) 67 (16.8%) + Death 6 (40%) 5 (17.9%) 4 (16.7%) 15 (22.4%) + Lost To Follow-Up 1 (6.7%) 3 (10.7%) 8 (33.3%) 12 (17.9%) + Other 2 (13.3%) 6 (21.4%) 5 (20.8%) 13 (19.4%) + Protocol Violation 4 (26.7%) 4 (14.3%) 4 (16.7%) 12 (17.9%) + Withdrawal By Subject 2 (13.3%) 10 (35.7%) 3 (12.5%) 15 (22.4%) + +# DST01 variant with grouping of reasons is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————— + Received treatment 134 (100.00%) 134 (100.00%) 132 (100.00%) 400 (100.00%) + Discontinued treatment 70 (52.2%) 65 (48.5%) 68 (51.5%) 203 (50.7%) + Safety 21 (15.7%) 28 (20.9%) 26 (19.7%) 75 (18.8%) + ADVERSE EVENT 10 (47.6%) 10 (35.7%) 11 (42.3%) 31 (41.3%) + PHYSICIAN DECISION 11 (52.4%) 18 (64.3%) 15 (57.7%) 44 (58.7%) + Other 49 (36.6%) 37 (27.6%) 42 (31.8%) 128 (32.0%) + LACK OF EFFICACY 14 (28.6%) 14 (37.8%) 10 (23.8%) 38 (29.7%) + OTHER 20 (40.8%) 10 (27%) 15 (35.7%) 45 (35.2%) + PROGRESSIVE DISEASE 15 (30.6%) 13 (35.1%) 17 (40.5%) 45 (35.2%) + +# DST01 variant with adding other optional rows is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————— + Completed Study 65 (48.51%) 67 (50.00%) 69 (52.27%) 201 (50.25%) + Alive: In Follow-up 25 (46.30%) 20 (51.28%) 18 (46.15%) 63 (47.73%) + Discontinued Study 15 (11.2%) 28 (20.9%) 24 (18.2%) 67 (16.8%) + Death 6 (40%) 5 (17.9%) 4 (16.7%) 15 (22.4%) + Lost To Follow-Up 1 (6.7%) 3 (10.7%) 8 (33.3%) 12 (17.9%) + Other 2 (13.3%) 6 (21.4%) 5 (20.8%) 13 (19.4%) + Protocol Violation 4 (26.7%) 4 (14.3%) 4 (16.7%) 12 (17.9%) + Withdrawal By Subject 2 (13.3%) 10 (35.7%) 3 (12.5%) 15 (22.4%) + diff --git a/tests/testthat/_snaps/table_dth01.md b/tests/testthat/_snaps/table_dth01.md new file mode 100644 index 0000000000..2084bce284 --- /dev/null +++ b/tests/testthat/_snaps/table_dth01.md @@ -0,0 +1,88 @@ +# DTH01 variant 1 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————— + Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) + Primary cause of death + n 25 23 22 70 + ADVERSE EVENT 9 (36%) 7 (30.4%) 10 (45.5%) 26 (37.1%) + OTHER 8 (32%) 10 (43.5%) 6 (27.3%) 24 (34.3%) + PROGRESSIVE DISEASE 8 (32%) 6 (26.1%) 6 (27.3%) 20 (28.6%) + +# DTH01 variant 2 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) + Primary cause of death + n 25 23 22 70 + ADVERSE EVENT 9 (36%) 7 (30.4%) 10 (45.5%) 26 (37.1%) + OTHER 8 (32%) 10 (43.5%) 6 (27.3%) 24 (34.3%) + PROGRESSIVE DISEASE 8 (32%) 6 (26.1%) 6 (27.3%) 20 (28.6%) + LOST TO FOLLOW UP 2 (25%) 2 (20%) 2 (33.3%) 6 (25%) + MISSING 2 (25%) 3 (30%) 2 (33.3%) 7 (29.2%) + Post-study reporting of death 1 (12.5%) 2 (20%) 1 (16.7%) 4 (16.7%) + SUICIDE 2 (25%) 2 (20%) 1 (16.7%) 5 (20.8%) + UNKNOWN 1 (12.5%) 1 (10%) 0 2 (8.3%) + Days from last drug administration + n 25 23 22 70 + <=30 14 (56%) 11 (47.8%) 14 (63.6%) 39 (55.7%) + >30 11 (44%) 12 (52.2%) 8 (36.4%) 31 (44.3%) + Primary cause by days from last study drug administration + <=30 + n 14 11 14 39 + ADVERSE EVENT 4 (28.6%) 2 (18.2%) 6 (42.9%) 12 (30.8%) + OTHER 4 (28.6%) 6 (54.5%) 4 (28.6%) 14 (35.9%) + PROGRESSIVE DISEASE 6 (42.9%) 3 (27.3%) 4 (28.6%) 13 (33.3%) + >30 + n 11 12 8 31 + ADVERSE EVENT 5 (45.5%) 5 (41.7%) 4 (50%) 14 (45.2%) + OTHER 4 (36.4%) 4 (33.3%) 2 (25%) 10 (32.3%) + PROGRESSIVE DISEASE 2 (18.2%) 3 (25%) 2 (25%) 7 (22.6%) + +# DTH01 variant 3 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————— + Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) + Primary cause of death + n 25 23 22 70 + ADVERSE EVENT 9 (36%) 7 (30.4%) 10 (45.5%) 26 (37.1%) + PROGRESSIVE DISEASE 8 (32%) 6 (26.1%) 6 (27.3%) 20 (28.6%) + OTHER 8 (32%) 10 (43.5%) 6 (27.3%) 24 (34.3%) + Post study reporting of deaths 1 (12.5%) 2 (20.0%) 1 (16.7%) 4 (16.7%) + All other causes 7 (87.5%) 8 (80.0%) 5 (83.3%) 20 (83.3%) + +# DTH01 variant 4 is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————— + Total number of deaths 25 (18.7%) 23 (17.2%) 22 (16.7%) 70 (17.5%) + Primary cause of death + n 25 23 22 70 + ADVERSE EVENT 9 (36%) 7 (30.4%) 10 (45.5%) 26 (37.1%) + PROGRESSIVE DISEASE 8 (32%) 6 (26.1%) 6 (27.3%) 20 (28.6%) + OTHER 8 (32%) 10 (43.5%) 6 (27.3%) 24 (34.3%) + Post study reporting of deaths 1 (12.5%) 2 (20.0%) 1 (16.7%) 4 (16.7%) + All other causes 7 (87.5%) 8 (80.0%) 5 (83.3%) 20 (83.3%) + LOST TO FOLLOW UP 2 (28.6%) 2 (25%) 2 (40%) 6 (30%) + SUICIDE 2 (28.6%) 2 (25%) 1 (20%) 5 (25%) + UNKNOWN 1 (14.3%) 1 (12.5%) 0 2 (10%) + MISSING 2 (28.6%) 3 (37.5%) 2 (40%) 7 (35%) + diff --git a/tests/testthat/_snaps/table_egt01.md b/tests/testthat/_snaps/table_egt01.md new file mode 100644 index 0000000000..52cfdb8d48 --- /dev/null +++ b/tests/testthat/_snaps/table_egt01.md @@ -0,0 +1,49 @@ +# EGT01 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Analysis Value Absolute Change from Baseline Analysis Value Absolute Change from Baseline Analysis Value Absolute Change from Baseline + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + BASELINE + n 134 0 134 0 132 0 + Mean (SD) 71.4 (17.9) NA 69.8 (20.7) NA 69.3 (20.9) NA + Median 72.7 NA 73.4 NA 72.0 NA + Min - Max 9.1 - 106.9 NA 13.5 - 115.5 NA 11.6 - 115.5 NA + WEEK 1 DAY 8 + n 134 134 134 134 132 132 + Mean (SD) 70.2 (20.3) -1.3 (26.0) 69.4 (20.8) -0.4 (29.7) 68.7 (18.1) -0.7 (27.8) + Median 70.7 -2.2 70.5 -0.5 68.6 -0.8 + Min - Max 8.5 - 127.5 -51.0 - 89.2 16.9 - 129.1 -68.2 - 88.4 16.9 - 115.6 -68.2 - 67.2 + WEEK 2 DAY 15 + n 134 134 134 134 132 132 + Mean (SD) 70.3 (19.6) -1.1 (26.3) 71.1 (20.6) 1.3 (31.4) 69.2 (18.1) -0.1 (28.6) + Median 70.9 -1.1 72.5 -0.3 69.3 -1.5 + Min - Max 17.1 - 116.3 -85.0 - 67.5 9.2 - 120.5 -73.1 - 81.4 29.6 - 120.5 -67.7 - 66.3 + WEEK 3 DAY 22 + n 134 134 134 134 132 132 + Mean (SD) 68.3 (20.2) -3.2 (28.7) 68.9 (20.6) -0.9 (30.1) 70.9 (20.3) 1.5 (27.3) + Median 68.8 -2.2 67.8 1.2 70.1 0.1 + Min - Max 13.3 - 131.7 -81.2 - 72.6 24.0 - 130.4 -73.0 - 103.3 20.9 - 116.8 -64.5 - 72.5 + WEEK 4 DAY 29 + n 134 134 134 134 132 132 + Mean (SD) 70.1 (18.4) -1.4 (26.6) 71.6 (20.3) 1.8 (30.3) 71.0 (20.6) 1.7 (29.6) + Median 69.3 -4.5 72.2 -0.9 70.5 3.8 + Min - Max 22.3 - 116.5 -58.1 - 77.3 17.5 - 129.1 -64.3 - 85.3 10.4 - 117.3 -65.9 - 105.7 + WEEK 5 DAY 36 + n 134 134 134 134 132 132 + Mean (SD) 66.4 (19.7) -5.0 (27.1) 71.3 (18.9) 1.4 (27.1) 71.3 (18.6) 1.9 (29.6) + Median 65.4 -6.8 70.9 0.6 73.3 1.7 + Min - Max 23.9 - 110.4 -73.3 - 57.2 25.9 - 125.7 -71.2 - 67.4 23.9 - 117.2 -58.2 - 68.9 + POST-BASELINE MINIMUM + n 134 134 134 134 132 132 + Mean (SD) 46.2 (12.2) -25.2 (23.2) 47.1 (14.1) -22.7 (26.0) 47.4 (12.6) -21.9 (24.7) + Median 47.3 -26.1 47.3 -24.3 48.2 -24.9 + Min - Max 8.5 - 85.6 -85.0 - 45.9 9.2 - 83.0 -73.1 - 47.0 10.4 - 80.4 -68.2 - 45.3 + POST-BASELINE MAXIMUM + n 134 134 134 134 132 132 + Mean (SD) 91.7 (13.9) 20.2 (22.8) 93.5 (14.4) 23.6 (26.5) 92.6 (12.1) 23.3 (23.1) + Median 90.0 16.6 91.0 22.9 93.4 22.1 + Min - Max 54.0 - 131.7 -31.1 - 89.2 63.6 - 130.4 -33.1 - 103.3 65.7 - 120.5 -28.5 - 105.7 + diff --git a/tests/testthat/_snaps/table_egt02.md b/tests/testthat/_snaps/table_egt02.md new file mode 100644 index 0000000000..b383d5afe2 --- /dev/null +++ b/tests/testthat/_snaps/table_egt02.md @@ -0,0 +1,38 @@ +# (EGT02) 1. Regardless of Abnormality at Baseline + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Parameter / Analysis Reference Range Indicator + Heart Rate + Low 40/134 (29.9%) 43/134 (32.1%) 37/132 (28%) 120/400 (30%) + High 39/134 (29.1%) 45/134 (33.6%) 36/132 (27.3%) 120/400 (30%) + QT Duration + Low 33/134 (24.6%) 44/134 (32.8%) 47/132 (35.6%) 124/400 (31%) + High 30/134 (22.4%) 42/134 (31.3%) 34/132 (25.8%) 106/400 (26.5%) + RR Duration + Low 45/134 (33.6%) 26/134 (19.4%) 38/132 (28.8%) 109/400 (27.3%) + High 29/134 (21.6%) 49/134 (36.6%) 27/132 (20.5%) 105/400 (26.2%) + +# (EGT02) 2. Among Subjects Without Abnormality at Baseline + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Parameter / Analysis Reference Range Indicator + Heart Rate + Low 39/128 (30.5%) 42/124 (33.9%) 33/117 (28.2%) 114/369 (30.9%) + High 37/127 (29.1%) 43/129 (33.3%) 31/122 (25.4%) 111/378 (29.4%) + QT Duration + Low 29/113 (25.7%) 42/126 (33.3%) 43/124 (34.7%) 114/363 (31.4%) + High 30/125 (24%) 40/130 (30.8%) 30/119 (25.2%) 100/374 (26.7%) + RR Duration + Low 45/129 (34.9%) 26/123 (21.1%) 37/126 (29.4%) 108/378 (28.6%) + High 27/127 (21.3%) 43/122 (35.2%) 25/125 (20%) 95/374 (25.4%) + diff --git a/tests/testthat/_snaps/table_egt03.md b/tests/testthat/_snaps/table_egt03.md new file mode 100644 index 0000000000..9ed871e1d7 --- /dev/null +++ b/tests/testthat/_snaps/table_egt03.md @@ -0,0 +1,101 @@ +# EGT03 variant 1 is produced correctly + + Code + res + Output + LOW NORMAL HIGH Missing + —————————————————————————————————————————————————————————————————— + A: Drug X (N=134) + n 40 92 0 2 + LOW 1 (0.7%) 5 (3.7%) 0 0 + NORMAL 36 (26.9%) 83 (61.9%) 0 1 (0.7%) + HIGH 2 (1.5%) 4 (3%) 0 0 + Missing 1 (0.7%) 0 0 1 (0.7%) + B: Placebo (N=134) + n 43 89 0 2 + LOW 1 (0.7%) 9 (6.7%) 0 0 + NORMAL 40 (29.9%) 75 (56%) 0 2 (1.5%) + HIGH 1 (0.7%) 4 (3%) 0 0 + Missing 1 (0.7%) 1 (0.7%) 0 0 + C: Combination (N=132) + n 37 94 0 1 + LOW 4 (3%) 11 (8.3%) 0 0 + NORMAL 31 (23.5%) 75 (56.8%) 0 0 + HIGH 1 (0.8%) 8 (6.1%) 0 1 (0.8%) + Missing 1 (0.8%) 0 0 0 + +# EGT03 variant 2 is produced correctly + + Code + res + Output + LOW NORMAL HIGH + ——————————————————————————————————————————————————————— + A: Drug X (N=134) + n 40 94 0 + LOW 1 (0.7%) 5 (3.7%) 0 + NORMAL 36 (26.9%) 84 (62.7%) 0 + HIGH 2 (1.5%) 4 (3%) 0 + Missing 1 (0.7%) 1 (0.7%) 0 + B: Placebo (N=134) + n 43 91 0 + LOW 1 (0.7%) 9 (6.7%) 0 + NORMAL 40 (29.9%) 77 (57.5%) 0 + HIGH 1 (0.7%) 4 (3%) 0 + Missing 1 (0.7%) 1 (0.7%) 0 + C: Combination (N=132) + n 37 95 0 + LOW 4 (3%) 11 (8.3%) 0 + NORMAL 31 (23.5%) 75 (56.8%) 0 + HIGH 1 (0.8%) 9 (6.8%) 0 + Missing 1 (0.8%) 0 0 + +# EGT03 variant 3 is produced correctly + + Code + res + Output + LOW NORMAL HIGH Missing + —————————————————————————————————————————————————————————————————— + A: Drug X (N=134) + n 39 93 0 2 + LOW 1 (0.7%) 5 (3.7%) 0 0 + NORMAL 36 (26.9%) 84 (62.7%) 0 1 (0.7%) + HIGH 2 (1.5%) 4 (3%) 0 1 (0.7%) + B: Placebo (N=134) + n 42 90 0 2 + LOW 1 (0.7%) 9 (6.7%) 0 0 + NORMAL 40 (29.9%) 77 (57.5%) 0 2 (1.5%) + HIGH 1 (0.7%) 4 (3%) 0 0 + C: Combination (N=132) + n 36 95 0 1 + LOW 4 (3%) 11 (8.3%) 0 0 + NORMAL 31 (23.5%) 75 (56.8%) 0 1 (0.8%) + HIGH 1 (0.8%) 9 (6.8%) 0 0 + +# EGT03 variant 4 is produced correctly + + Code + res + Output + LOW NORMAL HIGH Missing + ————————————————————————————————————————————————————————————————— + A: Drug X (N=134) + n 0 95 37 2 + LOW 0 2 (1.5%) 4 (3%) 0 + NORMAL 0 88 (65.7%) 31 (23.1%) 1 (0.7%) + HIGH 0 5 (3.7%) 1 (0.7%) 0 + Missing 0 0 1 (0.7%) 1 (0.7%) + B: Placebo (N=134) + n 0 88 44 2 + LOW 0 8 (6%) 2 (1.5%) 0 + NORMAL 0 76 (56.7%) 39 (29.1%) 2 (1.5%) + HIGH 0 3 (2.2%) 2 (1.5%) 0 + Missing 0 1 (0.7%) 1 (0.7%) 0 + C: Combination (N=132) + n 0 96 35 1 + LOW 0 12 (9.1%) 3 (2.3%) 0 + NORMAL 0 79 (59.8%) 27 (20.5%) 0 + HIGH 0 5 (3.8%) 4 (3%) 1 (0.8%) + Missing 0 0 1 (0.8%) 0 + diff --git a/tests/testthat/_snaps/table_egt04.md b/tests/testthat/_snaps/table_egt04.md new file mode 100644 index 0000000000..142ab71460 --- /dev/null +++ b/tests/testthat/_snaps/table_egt04.md @@ -0,0 +1,20 @@ +# EGT04 default variant is produced correctly + + Code + res + Output + Normal Abnormal Missing + ——————————————————————————————————————————————————————————— + A: Drug X (N=134) + Normal 20 (14.9%) 81 (60.4%) 1 (0.7%) + Abnormal 11 (8.2%) 19 (14.2%) 0 + Missing 0 1 (0.7%) 1 (0.7%) + B: Placebo (N=134) + Normal 18 (13.4%) 81 (60.4%) 2 (1.5%) + Abnormal 3 (2.2%) 28 (20.9%) 0 + Missing 0 2 (1.5%) 0 + C: Combination (N=132) + Normal 26 (19.7%) 69 (52.3%) 1 (0.8%) + Abnormal 6 (4.5%) 29 (22%) 0 + Missing 1 (0.8%) 0 0 + diff --git a/tests/testthat/_snaps/table_egt05_qtcat.md b/tests/testthat/_snaps/table_egt05_qtcat.md new file mode 100644 index 0000000000..6c174a7b33 --- /dev/null +++ b/tests/testthat/_snaps/table_egt05_qtcat.md @@ -0,0 +1,77 @@ +# EGT05_QTCAT default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————— + Visit + BASELINE + Value at Visit + n 134 134 132 + <=450 msec 115 (85.8%) 117 (87.3%) 104 (78.8%) + >450 to <=480 msec 6 (4.5%) 10 (7.5%) 9 (6.8%) + >480 to <= 500 msec 4 (3%) 3 (2.2%) 6 (4.5%) + >500 msec 9 (6.7%) 4 (3%) 13 (9.8%) + WEEK 1 DAY 8 + Value at Visit + n 134 134 132 + <=450 msec 113 (84.3%) 106 (79.1%) 106 (80.3%) + >450 to <=480 msec 10 (7.5%) 10 (7.5%) 11 (8.3%) + >480 to <= 500 msec 4 (3%) 4 (3%) 3 (2.3%) + >500 msec 7 (5.2%) 14 (10.4%) 12 (9.1%) + Change from Baseline + n 134 134 132 + <=30 msec 76 (56.7%) 75 (56%) 75 (56.8%) + >30 to <=60 msec 7 (5.2%) 13 (9.7%) 11 (8.3%) + >60 msec 51 (38.1%) 46 (34.3%) 46 (34.8%) + WEEK 2 DAY 15 + Value at Visit + n 134 134 132 + <=450 msec 111 (82.8%) 114 (85.1%) 112 (84.8%) + >450 to <=480 msec 10 (7.5%) 9 (6.7%) 9 (6.8%) + >480 to <= 500 msec 7 (5.2%) 2 (1.5%) 5 (3.8%) + >500 msec 6 (4.5%) 9 (6.7%) 6 (4.5%) + Change from Baseline + n 134 134 132 + <=30 msec 71 (53%) 87 (64.9%) 89 (67.4%) + >30 to <=60 msec 11 (8.2%) 9 (6.7%) 9 (6.8%) + >60 msec 52 (38.8%) 38 (28.4%) 34 (25.8%) + WEEK 3 DAY 22 + Value at Visit + n 134 134 132 + <=450 msec 106 (79.1%) 112 (83.6%) 118 (89.4%) + >450 to <=480 msec 13 (9.7%) 7 (5.2%) 3 (2.3%) + >480 to <= 500 msec 4 (3%) 5 (3.7%) 2 (1.5%) + >500 msec 11 (8.2%) 10 (7.5%) 9 (6.8%) + Change from Baseline + n 134 134 132 + <=30 msec 63 (47%) 80 (59.7%) 81 (61.4%) + >30 to <=60 msec 14 (10.4%) 8 (6%) 11 (8.3%) + >60 msec 57 (42.5%) 46 (34.3%) 40 (30.3%) + WEEK 4 DAY 29 + Value at Visit + n 134 134 132 + <=450 msec 117 (87.3%) 103 (76.9%) 114 (86.4%) + >450 to <=480 msec 7 (5.2%) 14 (10.4%) 6 (4.5%) + >480 to <= 500 msec 4 (3%) 7 (5.2%) 3 (2.3%) + >500 msec 6 (4.5%) 10 (7.5%) 9 (6.8%) + Change from Baseline + n 134 134 132 + <=30 msec 79 (59%) 80 (59.7%) 79 (59.8%) + >30 to <=60 msec 11 (8.2%) 7 (5.2%) 10 (7.6%) + >60 msec 44 (32.8%) 47 (35.1%) 43 (32.6%) + WEEK 5 DAY 36 + Value at Visit + n 134 134 132 + <=450 msec 107 (79.9%) 117 (87.3%) 112 (84.8%) + >450 to <=480 msec 16 (11.9%) 5 (3.7%) 13 (9.8%) + >480 to <= 500 msec 5 (3.7%) 9 (6.7%) 3 (2.3%) + >500 msec 6 (4.5%) 3 (2.2%) 4 (3%) + Change from Baseline + n 134 134 132 + <=30 msec 72 (53.7%) 82 (61.2%) 73 (55.3%) + >30 to <=60 msec 10 (7.5%) 11 (8.2%) 11 (8.3%) + >60 msec 52 (38.8%) 41 (30.6%) 48 (36.4%) + diff --git a/tests/testthat/_snaps/table_ent.md b/tests/testthat/_snaps/table_ent.md new file mode 100644 index 0000000000..6a526e156e --- /dev/null +++ b/tests/testthat/_snaps/table_ent.md @@ -0,0 +1,464 @@ +# ENT01_IT is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ——————————————————————————————————————————————————————————————————————————— + Africa 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + INV ID NGA-1 3 (2.2%) 3 (2.2%) 4 (3.0%) 10 (2.5%) + INV ID NGA-11 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID NGA-12 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID NGA-17 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID NGA-2 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID NGA-4 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID NGA-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID NGA-6 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + Asia 91 (67.9%) 94 (70.1%) 83 (62.9%) 268 (67.0%) + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + INV ID CHN-1 21 (15.7%) 20 (14.9%) 16 (12.1%) 57 (14.2%) + INV ID CHN-10 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID CHN-11 12 (9.0%) 20 (14.9%) 16 (12.1%) 48 (12.0%) + INV ID CHN-12 4 (3.0%) 3 (2.2%) 1 (0.8%) 8 (2.0%) + INV ID CHN-13 2 (1.5%) 6 (4.5%) 0 (0.0%) 8 (2.0%) + INV ID CHN-14 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID CHN-15 2 (1.5%) 0 (0.0%) 4 (3.0%) 6 (1.5%) + INV ID CHN-16 0 (0.0%) 3 (2.2%) 3 (2.3%) 6 (1.5%) + INV ID CHN-17 4 (3.0%) 4 (3.0%) 3 (2.3%) 11 (2.8%) + INV ID CHN-18 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID CHN-2 9 (6.7%) 4 (3.0%) 3 (2.3%) 16 (4.0%) + INV ID CHN-3 5 (3.7%) 1 (0.7%) 5 (3.8%) 11 (2.8%) + INV ID CHN-4 3 (2.2%) 3 (2.2%) 3 (2.3%) 9 (2.2%) + INV ID CHN-5 4 (3.0%) 3 (2.2%) 4 (3.0%) 11 (2.8%) + INV ID CHN-6 1 (0.7%) 3 (2.2%) 0 (0.0%) 4 (1.0%) + INV ID CHN-7 0 (0.0%) 5 (3.7%) 1 (0.8%) 6 (1.5%) + INV ID CHN-8 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CHN-9 1 (0.7%) 2 (1.5%) 0 (0.0%) 3 (0.8%) + PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + INV ID PAK-1 2 (1.5%) 4 (3.0%) 4 (3.0%) 10 (2.5%) + INV ID PAK-11 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID PAK-12 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID PAK-13 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID PAK-14 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-15 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-2 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID PAK-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID PAK-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) + INV ID JPN-1 2 (1.5%) 2 (1.5%) 1 (0.8%) 5 (1.2%) + INV ID JPN-11 0 (0.0%) 0 (0.0%) 3 (2.3%) 3 (0.8%) + INV ID JPN-12 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-14 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-17 0 (0.0%) 0 (0.0%) 2 (1.5%) 2 (0.5%) + INV ID JPN-18 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID JPN-2 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-3 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-5 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID JPN-6 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + Eurasia 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) + RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) + INV ID RUS-1 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-11 0 (0.0%) 2 (1.5%) 2 (1.5%) 4 (1.0%) + INV ID RUS-12 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-13 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-14 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-16 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID RUS-18 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-2 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-3 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-4 0 (0.0%) 2 (1.5%) 1 (0.8%) 3 (0.8%) + INV ID RUS-5 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-6 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-7 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + Europe 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID GBR-1 2 (1.5%) 0 (0.0%) 1 (0.8%) 3 (0.8%) + INV ID GBR-11 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID GBR-13 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-15 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-17 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID GBR-6 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + North America 13 (9.7%) 15 (11.2%) 20 (15.2%) 48 (12.0%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) + INV ID USA-1 1 (0.7%) 4 (3.0%) 5 (3.8%) 10 (2.5%) + INV ID USA-11 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID USA-12 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID USA-14 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID USA-15 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-17 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID USA-19 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-2 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-3 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID USA-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-5 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-6 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-8 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-9 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) + INV ID CAN-1 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CAN-11 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID CAN-14 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID CAN-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID CAN-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + South America 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + INV ID BRA-1 4 (3.0%) 2 (1.5%) 2 (1.5%) 8 (2.0%) + INV ID BRA-11 4 (3.0%) 0 (0.0%) 4 (3.0%) 8 (2.0%) + INV ID BRA-12 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID BRA-13 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-14 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID BRA-15 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-2 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID BRA-3 0 (0.0%) 2 (1.5%) 0 (0.0%) 2 (0.5%) + INV ID BRA-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID BRA-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID BRA-6 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-7 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + +# ENT01a_IT is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ————————————————————————————————————————————————————————————————————————— + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + INV ID CHN-1 21 (15.7%) 20 (14.9%) 16 (12.1%) 57 (14.2%) + INV ID CHN-10 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID CHN-11 12 (9.0%) 20 (14.9%) 16 (12.1%) 48 (12.0%) + INV ID CHN-12 4 (3.0%) 3 (2.2%) 1 (0.8%) 8 (2.0%) + INV ID CHN-13 2 (1.5%) 6 (4.5%) 0 (0.0%) 8 (2.0%) + INV ID CHN-14 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID CHN-15 2 (1.5%) 0 (0.0%) 4 (3.0%) 6 (1.5%) + INV ID CHN-16 0 (0.0%) 3 (2.2%) 3 (2.3%) 6 (1.5%) + INV ID CHN-17 4 (3.0%) 4 (3.0%) 3 (2.3%) 11 (2.8%) + INV ID CHN-18 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID CHN-2 9 (6.7%) 4 (3.0%) 3 (2.3%) 16 (4.0%) + INV ID CHN-3 5 (3.7%) 1 (0.7%) 5 (3.8%) 11 (2.8%) + INV ID CHN-4 3 (2.2%) 3 (2.2%) 3 (2.3%) 9 (2.2%) + INV ID CHN-5 4 (3.0%) 3 (2.2%) 4 (3.0%) 11 (2.8%) + INV ID CHN-6 1 (0.7%) 3 (2.2%) 0 (0.0%) 4 (1.0%) + INV ID CHN-7 0 (0.0%) 5 (3.7%) 1 (0.8%) 6 (1.5%) + INV ID CHN-8 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CHN-9 1 (0.7%) 2 (1.5%) 0 (0.0%) 3 (0.8%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) + INV ID USA-1 1 (0.7%) 4 (3.0%) 5 (3.8%) 10 (2.5%) + INV ID USA-11 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID USA-12 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID USA-14 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID USA-15 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-17 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID USA-19 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-2 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-3 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID USA-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-5 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-6 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-8 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-9 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + INV ID BRA-1 4 (3.0%) 2 (1.5%) 2 (1.5%) 8 (2.0%) + INV ID BRA-11 4 (3.0%) 0 (0.0%) 4 (3.0%) 8 (2.0%) + INV ID BRA-12 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID BRA-13 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-14 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID BRA-15 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-2 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID BRA-3 0 (0.0%) 2 (1.5%) 0 (0.0%) 2 (0.5%) + INV ID BRA-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID BRA-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID BRA-6 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-7 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + INV ID PAK-1 2 (1.5%) 4 (3.0%) 4 (3.0%) 10 (2.5%) + INV ID PAK-11 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID PAK-12 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID PAK-13 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID PAK-14 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-15 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-2 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID PAK-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID PAK-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + INV ID NGA-1 3 (2.2%) 3 (2.2%) 4 (3.0%) 10 (2.5%) + INV ID NGA-11 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID NGA-12 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID NGA-17 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID NGA-2 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID NGA-4 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID NGA-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID NGA-6 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) + INV ID RUS-1 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-11 0 (0.0%) 2 (1.5%) 2 (1.5%) 4 (1.0%) + INV ID RUS-12 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-13 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-14 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-16 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID RUS-18 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-2 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-3 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-4 0 (0.0%) 2 (1.5%) 1 (0.8%) 3 (0.8%) + INV ID RUS-5 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-6 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-7 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) + INV ID JPN-1 2 (1.5%) 2 (1.5%) 1 (0.8%) 5 (1.2%) + INV ID JPN-11 0 (0.0%) 0 (0.0%) 3 (2.3%) 3 (0.8%) + INV ID JPN-12 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-14 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-17 0 (0.0%) 0 (0.0%) 2 (1.5%) 2 (0.5%) + INV ID JPN-18 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID JPN-2 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-3 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-5 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID JPN-6 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID GBR-1 2 (1.5%) 0 (0.0%) 1 (0.8%) 3 (0.8%) + INV ID GBR-11 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID GBR-13 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-15 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-17 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID GBR-6 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) + INV ID CAN-1 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CAN-11 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID CAN-14 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID CAN-4 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID CAN-5 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + +# ENT02_IT is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ———————————————————————————————————————————————————————————————————————————————————————————— + Africa 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + INV ID NGA-1 / Dr. NGA-1 Doe 3 (2.2%) 3 (2.2%) 4 (3.0%) 10 (2.5%) + INV ID NGA-11 / Dr. NGA-11 Doe 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID NGA-12 / Dr. NGA-12 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID NGA-17 / Dr. NGA-17 Doe 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID NGA-2 / Dr. NGA-2 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID NGA-4 / Dr. NGA-4 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID NGA-5 / Dr. NGA-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID NGA-6 / Dr. NGA-6 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + Asia 91 (67.9%) 94 (70.1%) 83 (62.9%) 268 (67.0%) + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + INV ID CHN-1 / Dr. CHN-1 Doe 21 (15.7%) 20 (14.9%) 16 (12.1%) 57 (14.2%) + INV ID CHN-10 / Dr. CHN-10 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID CHN-11 / Dr. CHN-11 Doe 12 (9.0%) 20 (14.9%) 16 (12.1%) 48 (12.0%) + INV ID CHN-12 / Dr. CHN-12 Doe 4 (3.0%) 3 (2.2%) 1 (0.8%) 8 (2.0%) + INV ID CHN-13 / Dr. CHN-13 Doe 2 (1.5%) 6 (4.5%) 0 (0.0%) 8 (2.0%) + INV ID CHN-14 / Dr. CHN-14 Doe 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID CHN-15 / Dr. CHN-15 Doe 2 (1.5%) 0 (0.0%) 4 (3.0%) 6 (1.5%) + INV ID CHN-16 / Dr. CHN-16 Doe 0 (0.0%) 3 (2.2%) 3 (2.3%) 6 (1.5%) + INV ID CHN-17 / Dr. CHN-17 Doe 4 (3.0%) 4 (3.0%) 3 (2.3%) 11 (2.8%) + INV ID CHN-18 / Dr. CHN-18 Doe 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID CHN-2 / Dr. CHN-2 Doe 9 (6.7%) 4 (3.0%) 3 (2.3%) 16 (4.0%) + INV ID CHN-3 / Dr. CHN-3 Doe 5 (3.7%) 1 (0.7%) 5 (3.8%) 11 (2.8%) + INV ID CHN-4 / Dr. CHN-4 Doe 3 (2.2%) 3 (2.2%) 3 (2.3%) 9 (2.2%) + INV ID CHN-5 / Dr. CHN-5 Doe 4 (3.0%) 3 (2.2%) 4 (3.0%) 11 (2.8%) + INV ID CHN-6 / Dr. CHN-6 Doe 1 (0.7%) 3 (2.2%) 0 (0.0%) 4 (1.0%) + INV ID CHN-7 / Dr. CHN-7 Doe 0 (0.0%) 5 (3.7%) 1 (0.8%) 6 (1.5%) + INV ID CHN-8 / Dr. CHN-8 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CHN-9 / Dr. CHN-9 Doe 1 (0.7%) 2 (1.5%) 0 (0.0%) 3 (0.8%) + PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + INV ID PAK-1 / Dr. PAK-1 Doe 2 (1.5%) 4 (3.0%) 4 (3.0%) 10 (2.5%) + INV ID PAK-11 / Dr. PAK-11 Doe 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID PAK-12 / Dr. PAK-12 Doe 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID PAK-13 / Dr. PAK-13 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID PAK-14 / Dr. PAK-14 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-15 / Dr. PAK-15 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-2 / Dr. PAK-2 Doe 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID PAK-4 / Dr. PAK-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID PAK-5 / Dr. PAK-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) + INV ID JPN-1 / Dr. JPN-1 Doe 2 (1.5%) 2 (1.5%) 1 (0.8%) 5 (1.2%) + INV ID JPN-11 / Dr. JPN-11 Doe 0 (0.0%) 0 (0.0%) 3 (2.3%) 3 (0.8%) + INV ID JPN-12 / Dr. JPN-12 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-14 / Dr. JPN-14 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-17 / Dr. JPN-17 Doe 0 (0.0%) 0 (0.0%) 2 (1.5%) 2 (0.5%) + INV ID JPN-18 / Dr. JPN-18 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID JPN-2 / Dr. JPN-2 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-3 / Dr. JPN-3 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-5 / Dr. JPN-5 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID JPN-6 / Dr. JPN-6 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + Eurasia 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) + RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) + INV ID RUS-1 / Dr. RUS-1 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-11 / Dr. RUS-11 Doe 0 (0.0%) 2 (1.5%) 2 (1.5%) 4 (1.0%) + INV ID RUS-12 / Dr. RUS-12 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-13 / Dr. RUS-13 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-14 / Dr. RUS-14 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-16 / Dr. RUS-16 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID RUS-18 / Dr. RUS-18 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-2 / Dr. RUS-2 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-3 / Dr. RUS-3 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-4 / Dr. RUS-4 Doe 0 (0.0%) 2 (1.5%) 1 (0.8%) 3 (0.8%) + INV ID RUS-5 / Dr. RUS-5 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-6 / Dr. RUS-6 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-7 / Dr. RUS-7 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + Europe 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID GBR-1 / Dr. GBR-1 Doe 2 (1.5%) 0 (0.0%) 1 (0.8%) 3 (0.8%) + INV ID GBR-11 / Dr. GBR-11 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID GBR-13 / Dr. GBR-13 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-15 / Dr. GBR-15 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-17 / Dr. GBR-17 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID GBR-6 / Dr. GBR-6 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + North America 13 (9.7%) 15 (11.2%) 20 (15.2%) 48 (12.0%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) + INV ID USA-1 / Dr. USA-1 Doe 1 (0.7%) 4 (3.0%) 5 (3.8%) 10 (2.5%) + INV ID USA-11 / Dr. USA-11 Doe 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID USA-12 / Dr. USA-12 Doe 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID USA-14 / Dr. USA-14 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID USA-15 / Dr. USA-15 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-17 / Dr. USA-17 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID USA-19 / Dr. USA-19 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-2 / Dr. USA-2 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-3 / Dr. USA-3 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID USA-4 / Dr. USA-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-5 / Dr. USA-5 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-6 / Dr. USA-6 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-8 / Dr. USA-8 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-9 / Dr. USA-9 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) + INV ID CAN-1 / Dr. CAN-1 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CAN-11 / Dr. CAN-11 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID CAN-14 / Dr. CAN-14 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID CAN-4 / Dr. CAN-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID CAN-5 / Dr. CAN-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + South America 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + INV ID BRA-1 / Dr. BRA-1 Doe 4 (3.0%) 2 (1.5%) 2 (1.5%) 8 (2.0%) + INV ID BRA-11 / Dr. BRA-11 Doe 4 (3.0%) 0 (0.0%) 4 (3.0%) 8 (2.0%) + INV ID BRA-12 / Dr. BRA-12 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID BRA-13 / Dr. BRA-13 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-14 / Dr. BRA-14 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID BRA-15 / Dr. BRA-15 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-2 / Dr. BRA-2 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID BRA-3 / Dr. BRA-3 Doe 0 (0.0%) 2 (1.5%) 0 (0.0%) 2 (0.5%) + INV ID BRA-4 / Dr. BRA-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID BRA-5 / Dr. BRA-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID BRA-6 / Dr. BRA-6 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-7 / Dr. BRA-7 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + +# ENT02a_IT is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + —————————————————————————————————————————————————————————————————————————————————————————— + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + INV ID CHN-1 / Dr. CHN-1 Doe 21 (15.7%) 20 (14.9%) 16 (12.1%) 57 (14.2%) + INV ID CHN-10 / Dr. CHN-10 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID CHN-11 / Dr. CHN-11 Doe 12 (9.0%) 20 (14.9%) 16 (12.1%) 48 (12.0%) + INV ID CHN-12 / Dr. CHN-12 Doe 4 (3.0%) 3 (2.2%) 1 (0.8%) 8 (2.0%) + INV ID CHN-13 / Dr. CHN-13 Doe 2 (1.5%) 6 (4.5%) 0 (0.0%) 8 (2.0%) + INV ID CHN-14 / Dr. CHN-14 Doe 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID CHN-15 / Dr. CHN-15 Doe 2 (1.5%) 0 (0.0%) 4 (3.0%) 6 (1.5%) + INV ID CHN-16 / Dr. CHN-16 Doe 0 (0.0%) 3 (2.2%) 3 (2.3%) 6 (1.5%) + INV ID CHN-17 / Dr. CHN-17 Doe 4 (3.0%) 4 (3.0%) 3 (2.3%) 11 (2.8%) + INV ID CHN-18 / Dr. CHN-18 Doe 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID CHN-2 / Dr. CHN-2 Doe 9 (6.7%) 4 (3.0%) 3 (2.3%) 16 (4.0%) + INV ID CHN-3 / Dr. CHN-3 Doe 5 (3.7%) 1 (0.7%) 5 (3.8%) 11 (2.8%) + INV ID CHN-4 / Dr. CHN-4 Doe 3 (2.2%) 3 (2.2%) 3 (2.3%) 9 (2.2%) + INV ID CHN-5 / Dr. CHN-5 Doe 4 (3.0%) 3 (2.2%) 4 (3.0%) 11 (2.8%) + INV ID CHN-6 / Dr. CHN-6 Doe 1 (0.7%) 3 (2.2%) 0 (0.0%) 4 (1.0%) + INV ID CHN-7 / Dr. CHN-7 Doe 0 (0.0%) 5 (3.7%) 1 (0.8%) 6 (1.5%) + INV ID CHN-8 / Dr. CHN-8 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CHN-9 / Dr. CHN-9 Doe 1 (0.7%) 2 (1.5%) 0 (0.0%) 3 (0.8%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10.0%) + INV ID USA-1 / Dr. USA-1 Doe 1 (0.7%) 4 (3.0%) 5 (3.8%) 10 (2.5%) + INV ID USA-11 / Dr. USA-11 Doe 4 (3.0%) 2 (1.5%) 3 (2.3%) 9 (2.2%) + INV ID USA-12 / Dr. USA-12 Doe 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID USA-14 / Dr. USA-14 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID USA-15 / Dr. USA-15 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-17 / Dr. USA-17 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID USA-19 / Dr. USA-19 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-2 / Dr. USA-2 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-3 / Dr. USA-3 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID USA-4 / Dr. USA-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID USA-5 / Dr. USA-5 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-6 / Dr. USA-6 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID USA-8 / Dr. USA-8 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID USA-9 / Dr. USA-9 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + INV ID BRA-1 / Dr. BRA-1 Doe 4 (3.0%) 2 (1.5%) 2 (1.5%) 8 (2.0%) + INV ID BRA-11 / Dr. BRA-11 Doe 4 (3.0%) 0 (0.0%) 4 (3.0%) 8 (2.0%) + INV ID BRA-12 / Dr. BRA-12 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID BRA-13 / Dr. BRA-13 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-14 / Dr. BRA-14 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID BRA-15 / Dr. BRA-15 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-2 / Dr. BRA-2 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID BRA-3 / Dr. BRA-3 Doe 0 (0.0%) 2 (1.5%) 0 (0.0%) 2 (0.5%) + INV ID BRA-4 / Dr. BRA-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID BRA-5 / Dr. BRA-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID BRA-6 / Dr. BRA-6 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID BRA-7 / Dr. BRA-7 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + PAK 12 (9.0%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + INV ID PAK-1 / Dr. PAK-1 Doe 2 (1.5%) 4 (3.0%) 4 (3.0%) 10 (2.5%) + INV ID PAK-11 / Dr. PAK-11 Doe 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID PAK-12 / Dr. PAK-12 Doe 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID PAK-13 / Dr. PAK-13 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID PAK-14 / Dr. PAK-14 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-15 / Dr. PAK-15 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID PAK-2 / Dr. PAK-2 Doe 1 (0.7%) 0 (0.0%) 2 (1.5%) 3 (0.8%) + INV ID PAK-4 / Dr. PAK-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID PAK-5 / Dr. PAK-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + NGA 8 (6.0%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + INV ID NGA-1 / Dr. NGA-1 Doe 3 (2.2%) 3 (2.2%) 4 (3.0%) 10 (2.5%) + INV ID NGA-11 / Dr. NGA-11 Doe 1 (0.7%) 2 (1.5%) 3 (2.3%) 6 (1.5%) + INV ID NGA-12 / Dr. NGA-12 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID NGA-17 / Dr. NGA-17 Doe 2 (1.5%) 0 (0.0%) 0 (0.0%) 2 (0.5%) + INV ID NGA-2 / Dr. NGA-2 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID NGA-4 / Dr. NGA-4 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID NGA-5 / Dr. NGA-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID NGA-6 / Dr. NGA-6 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + RUS 5 (3.7%) 8 (6.0%) 6 (4.5%) 19 (4.8%) + INV ID RUS-1 / Dr. RUS-1 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-11 / Dr. RUS-11 Doe 0 (0.0%) 2 (1.5%) 2 (1.5%) 4 (1.0%) + INV ID RUS-12 / Dr. RUS-12 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-13 / Dr. RUS-13 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-14 / Dr. RUS-14 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-16 / Dr. RUS-16 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID RUS-18 / Dr. RUS-18 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-2 / Dr. RUS-2 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-3 / Dr. RUS-3 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID RUS-4 / Dr. RUS-4 Doe 0 (0.0%) 2 (1.5%) 1 (0.8%) 3 (0.8%) + INV ID RUS-5 / Dr. RUS-5 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID RUS-6 / Dr. RUS-6 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID RUS-7 / Dr. RUS-7 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + JPN 5 (3.7%) 4 (3.0%) 9 (6.8%) 18 (4.5%) + INV ID JPN-1 / Dr. JPN-1 Doe 2 (1.5%) 2 (1.5%) 1 (0.8%) 5 (1.2%) + INV ID JPN-11 / Dr. JPN-11 Doe 0 (0.0%) 0 (0.0%) 3 (2.3%) 3 (0.8%) + INV ID JPN-12 / Dr. JPN-12 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-14 / Dr. JPN-14 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-17 / Dr. JPN-17 Doe 0 (0.0%) 0 (0.0%) 2 (1.5%) 2 (0.5%) + INV ID JPN-18 / Dr. JPN-18 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID JPN-2 / Dr. JPN-2 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + INV ID JPN-3 / Dr. JPN-3 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID JPN-5 / Dr. JPN-5 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID JPN-6 / Dr. JPN-6 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + GBR 4 (3.0%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + INV ID GBR-1 / Dr. GBR-1 Doe 2 (1.5%) 0 (0.0%) 1 (0.8%) 3 (0.8%) + INV ID GBR-11 / Dr. GBR-11 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID GBR-13 / Dr. GBR-13 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-15 / Dr. GBR-15 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID GBR-17 / Dr. GBR-17 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + INV ID GBR-6 / Dr. GBR-6 Doe 0 (0.0%) 1 (0.7%) 0 (0.0%) 1 (0.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2.0%) + INV ID CAN-1 / Dr. CAN-1 Doe 1 (0.7%) 1 (0.7%) 0 (0.0%) 2 (0.5%) + INV ID CAN-11 / Dr. CAN-11 Doe 1 (0.7%) 0 (0.0%) 1 (0.8%) 2 (0.5%) + INV ID CAN-14 / Dr. CAN-14 Doe 1 (0.7%) 0 (0.0%) 0 (0.0%) 1 (0.2%) + INV ID CAN-4 / Dr. CAN-4 Doe 0 (0.0%) 1 (0.7%) 1 (0.8%) 2 (0.5%) + INV ID CAN-5 / Dr. CAN-5 Doe 0 (0.0%) 0 (0.0%) 1 (0.8%) 1 (0.2%) + diff --git a/tests/testthat/_snaps/table_ext01.md b/tests/testthat/_snaps/table_ext01.md new file mode 100644 index 0000000000..81ac547712 --- /dev/null +++ b/tests/testthat/_snaps/table_ext01.md @@ -0,0 +1,95 @@ +# EXT01 default variant with numeric parameters is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————————————— + Total dose administered + n 75 67 75 + Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5) + Median 6720.0 6480.0 7200.0 + Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0 + Total number of doses administered + n 75 67 75 + Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) + Median 7.0 7.0 7.0 + Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 + Treatment duration (days) + n 75 67 75 + Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) + Median 77.0 80.0 78.0 + Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 + Total number of missed doses during study + n 75 67 75 + Mean (SD) 10.5 (5.9) 10.0 (6.1) 9.5 (5.5) + Median 10.0 11.0 9.0 + Min - Max 0.0 - 20.0 0.0 - 19.0 0.0 - 20.0 + +# EXT01 variant: with both numeric and categorical parameters + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————— + Treatment duration (days) + n 75 67 75 + Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) + Median 77.0 80.0 78.0 + Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 + Treatment duration (days) + n 75 67 75 + 0 - 30 12 (16%) 12 (17.9%) 15 (20%) + 31 - 60 18 (24%) 12 (17.9%) 14 (18.7%) + 61 - 90 19 (25.3%) 15 (22.4%) 18 (24%) + >= 91 26 (34.7%) 28 (41.8%) 28 (37.3%) + Total dose administered + n 75 67 75 + Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5) + Median 6720.0 6480.0 7200.0 + Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0 + Total number of doses administered + n 75 67 75 + Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) + Median 7.0 7.0 7.0 + Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 + +# EXT01 variant: with user specified categories for missed doses + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————— + Treatment duration (days) + n 75 67 75 + Mean (SD) 74.3 (41.6) 79.0 (43.1) 74.2 (39.5) + Median 77.0 80.0 78.0 + Min - Max 5.0 - 149.0 2.0 - 150.0 1.0 - 147.0 + Treatment duration (days) + n 75 67 75 + 0 - 30 12 (16%) 12 (17.9%) 15 (20%) + 31 - 60 18 (24%) 12 (17.9%) 14 (18.7%) + 61 - 90 19 (25.3%) 15 (22.4%) 18 (24%) + >= 91 26 (34.7%) 28 (41.8%) 28 (37.3%) + Total dose administered + n 75 67 75 + Mean (SD) 6675.2 (1110.9) 6505.1 (1249.3) 6982.4 (1272.5) + Median 6720.0 6480.0 7200.0 + Min - Max 4800.0 - 9360.0 4080.0 - 9360.0 4320.0 - 9360.0 + Total number of doses administered + n 75 67 75 + Mean (SD) 7.0 (0.0) 7.0 (0.0) 7.0 (0.0) + Median 7.0 7.0 7.0 + Min - Max 7.0 - 7.0 7.0 - 7.0 7.0 - 7.0 + Missed Doses + n 75 67 75 + At least 1 missed dose 74 (55.2%) 63 (47%) 73 (55.3%) + At least 5 missed doses 59 (44%) 49 (36.6%) 59 (44.7%) + At least 10 missed doses 41 (30.6%) 38 (28.4%) 37 (28%) + At least 15 missed doses 26 (19.4%) 21 (15.7%) 16 (12.1%) + diff --git a/tests/testthat/_snaps/table_fstg02.md b/tests/testthat/_snaps/table_fstg02.md new file mode 100644 index 0000000000..b5120e4f71 --- /dev/null +++ b/tests/testthat/_snaps/table_fstg02.md @@ -0,0 +1,68 @@ +# FSTG02 table variant 1 (Subgroup Analysis of Survival Duration) is produced correctly + + Code + res + Output + Baseline Risk Factors B: Placebo A: Drug X + Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + All Patients 268 134 27.5 134 41.4 0.72 (0.53, 0.98) + Sex + F 161 82 28.0 79 41.9 0.70 (0.46, 1.05) + M 107 52 17.3 55 27.9 0.78 (0.49, 1.26) + Categorical Level Biomarker 2 + LOW 95 45 24.7 50 38.1 0.71 (0.42, 1.17) + MEDIUM 93 56 23.7 37 41.7 0.57 (0.32, 1.01) + HIGH 80 33 27.9 47 35.2 0.98 (0.56, 1.72) + +# FSTG02 table variant 2 (specifying class variables and options for the treatment variable) + + Code + res + Output + Baseline Risk Factors Placebo Drug X + Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————— + All Patients 268 134 27.5 134 41.4 0.72 (0.53, 0.98) + Sex + M 107 52 17.3 55 27.9 0.78 (0.49, 1.26) + F 161 82 28.0 79 41.9 0.70 (0.46, 1.05) + Stratification Factor 1 + C 94 45 16.3 49 54.7 0.53 (0.31, 0.90) + B 92 45 27.9 47 32.4 0.87 (0.53, 1.45) + A 82 44 35.7 38 35.2 0.86 (0.48, 1.53) + +# FSTG02 table variant 3 (selecting columns and changing the alpha level) + + Code + res + Output + Baseline Risk Factors + Total n Hazard Ratio 90% Wald CI + ————————————————————————————————————————————————————————————————————— + All Patients 268 0.72 (0.55, 0.93) + Sex + F 161 0.70 (0.50, 0.98) + M 107 0.78 (0.53, 1.17) + Categorical Level Biomarker 2 + LOW 95 0.71 (0.46, 1.08) + MEDIUM 93 0.57 (0.36, 0.92) + HIGH 80 0.98 (0.61, 1.57) + +# FSTG02 table variant 4 (fixed symbol size) is produced correctly + + Code + res + Output + Baseline Risk Factors B: Placebo A: Drug X + Total n n Median (Months) n Median (Months) Hazard Ratio 95% Wald CI + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + All Patients 268 134 27.5 134 41.4 0.72 (0.53, 0.98) + Sex + F 161 82 28.0 79 41.9 0.70 (0.46, 1.05) + M 107 52 17.3 55 27.9 0.78 (0.49, 1.26) + Categorical Level Biomarker 2 + LOW 95 45 24.7 50 38.1 0.71 (0.42, 1.17) + MEDIUM 93 56 23.7 37 41.7 0.57 (0.32, 1.01) + HIGH 80 33 27.9 47 35.2 0.98 (0.56, 1.72) + diff --git a/tests/testthat/_snaps/table_lbt01.md b/tests/testthat/_snaps/table_lbt01.md new file mode 100644 index 0000000000..e1de64ec8e --- /dev/null +++ b/tests/testthat/_snaps/table_lbt01.md @@ -0,0 +1,39 @@ +# LBT01 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Analysis Value Absolute Change from Baseline Analysis Value Absolute Change from Baseline Analysis Value Absolute Change from Baseline + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + BASELINE + n 134 134 134 134 132 132 + Mean (SD) 19.8 (4.2) 0.0 (0.0) 20.2 (4.2) 0.0 (0.0) 20.5 (3.9) 0.0 (0.0) + Median 19.8 0.0 20.1 0.0 20.4 0.0 + Min - Max 7.0 - 30.4 0.0 - 0.0 8.1 - 34.6 0.0 - 0.0 8.8 - 28.7 0.0 - 0.0 + WEEK 1 DAY 8 + n 134 134 0 0 132 132 + Mean (SD) 19.3 (4.0) -0.5 (5.9) NA NA 20.6 (3.9) 0.1 (5.5) + Median 19.2 -0.5 NA NA 20.4 0.0 + Min - Max 8.9 - 27.3 -12.5 - 19.7 NA NA 9.9 - 30.7 -13.7 - 15.5 + WEEK 2 DAY 15 + n 134 134 134 134 132 132 + Mean (SD) 19.7 (4.2) -0.1 (6.0) 20.1 (4.3) -0.0 (6.3) 19.2 (3.6) -1.2 (5.5) + Median 19.2 0.0 20.0 -0.4 19.6 -0.5 + Min - Max 7.2 - 30.5 -13.2 - 17.2 7.2 - 30.5 -18.4 - 14.4 8.1 - 26.7 -14.3 - 15.6 + WEEK 3 DAY 22 + n 134 134 134 134 132 132 + Mean (SD) 20.1 (3.8) 0.3 (5.8) 19.8 (3.9) -0.3 (5.6) 19.4 (3.9) -1.0 (5.6) + Median 20.0 0.5 19.9 -0.2 18.8 -1.1 + Min - Max 11.5 - 29.5 -16.0 - 16.3 11.9 - 28.2 -18.5 - 15.0 10.2 - 28.5 -12.3 - 11.1 + WEEK 4 DAY 29 + n 134 134 134 134 132 132 + Mean (SD) 20.4 (4.6) 0.6 (6.5) 19.6 (4.3) -0.5 (6.3) 19.8 (4.0) -0.6 (5.3) + Median 19.8 0.4 19.2 -1.2 19.9 -0.6 + Min - Max 9.9 - 34.5 -17.0 - 18.8 11.5 - 32.0 -16.6 - 17.2 7.8 - 29.3 -12.1 - 15.3 + WEEK 5 DAY 36 + n 134 134 134 134 132 132 + Mean (SD) 20.4 (3.9) 0.6 (6.1) 19.9 (4.2) -0.3 (6.3) 20.0 (4.2) -0.5 (5.6) + Median 20.7 0.9 20.1 0.7 20.5 -1.0 + Min - Max 10.9 - 30.2 -16.0 - 16.1 10.3 - 29.1 -19.0 - 12.6 7.4 - 27.8 -15.6 - 16.6 + diff --git a/tests/testthat/_snaps/table_lbt02.md b/tests/testthat/_snaps/table_lbt02.md new file mode 100644 index 0000000000..fbd035a02b --- /dev/null +++ b/tests/testthat/_snaps/table_lbt02.md @@ -0,0 +1,39 @@ +# LBT02 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————— + BASELINE + n 134 134 132 + Mean (SD) 19.8 (4.2) 20.2 (4.2) 20.5 (3.9) + Median 19.8 20.1 20.4 + Min - Max 7.0 - 30.4 8.1 - 34.6 8.8 - 28.7 + WEEK 1 DAY 8 + n 134 134 132 + Mean (SD) 19.3 (4.0) 20.2 (4.0) 20.6 (3.9) + Median 19.2 20.1 20.4 + Min - Max 8.9 - 27.3 5.8 - 28.8 9.9 - 30.7 + WEEK 2 DAY 15 + n 134 134 132 + Mean (SD) 19.7 (4.2) 20.1 (4.3) 19.2 (3.6) + Median 19.2 20.0 19.6 + Min - Max 7.2 - 30.5 7.2 - 30.5 8.1 - 26.7 + WEEK 3 DAY 22 + n 134 134 132 + Mean (SD) 20.1 (3.8) 19.8 (3.9) 19.4 (3.9) + Median 20.0 19.9 18.8 + Min - Max 11.5 - 29.5 11.9 - 28.2 10.2 - 28.5 + WEEK 4 DAY 29 + n 134 134 132 + Mean (SD) 20.4 (4.6) 19.6 (4.3) 19.8 (4.0) + Median 19.8 19.2 19.9 + Min - Max 9.9 - 34.5 11.5 - 32.0 7.8 - 29.3 + WEEK 5 DAY 36 + n 134 134 132 + Mean (SD) 20.4 (3.9) 19.9 (4.2) 20.0 (4.2) + Median 20.7 20.1 20.5 + Min - Max 10.9 - 30.2 10.3 - 29.1 7.4 - 27.8 + diff --git a/tests/testthat/_snaps/table_lbt03.md b/tests/testthat/_snaps/table_lbt03.md new file mode 100644 index 0000000000..0cb4349c07 --- /dev/null +++ b/tests/testthat/_snaps/table_lbt03.md @@ -0,0 +1,39 @@ +# LBT03 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————— + BASELINE + n 134 134 132 + Mean (SD) 19.79 (4.16) 20.15 (4.17) 20.45 (3.91) + Median 19.79 20.08 20.39 + Min - Max 6.99 - 30.43 8.11 - 34.56 8.82 - 28.72 + WEEK 1 DAY 8 + n 134 134 132 + Mean (SD) -0.48 (5.85) 0.07 (6.04) 0.10 (5.46) + Median -0.51 -0.72 0.03 + Min - Max -12.52 - 19.70 -12.29 - 17.41 -13.69 - 15.54 + WEEK 2 DAY 15 + n 134 134 132 + Mean (SD) -0.08 (6.00) -0.03 (6.26) -1.20 (5.49) + Median 0.04 -0.37 -0.48 + Min - Max -13.15 - 17.17 -18.37 - 14.39 -14.28 - 15.65 + WEEK 3 DAY 22 + n 134 134 132 + Mean (SD) 0.34 (5.76) -0.32 (5.60) -1.02 (5.55) + Median 0.45 -0.18 -1.07 + Min - Max -16.04 - 16.26 -18.52 - 15.00 -12.33 - 11.10 + WEEK 4 DAY 29 + n 134 134 132 + Mean (SD) 0.57 (6.51) -0.52 (6.29) -0.63 (5.31) + Median 0.35 -1.19 -0.65 + Min - Max -17.00 - 18.79 -16.58 - 17.23 -12.13 - 15.30 + WEEK 5 DAY 36 + n 134 134 132 + Mean (SD) 0.63 (6.05) -0.29 (6.31) -0.46 (5.57) + Median 0.93 0.73 -0.99 + Min - Max -16.03 - 16.09 -19.04 - 12.64 -15.62 - 16.61 + diff --git a/tests/testthat/_snaps/table_lbt04.md b/tests/testthat/_snaps/table_lbt04.md new file mode 100644 index 0000000000..0f66569b7e --- /dev/null +++ b/tests/testthat/_snaps/table_lbt04.md @@ -0,0 +1,20 @@ +# LBT04 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————————————————————————————————————————— + CHEMISTRY + Alanine Aminotransferase Measurement + Low 50/124 (40.3%) 46/122 (37.7%) 37/117 (31.6%) + High 49/121 (40.5%) 48/118 (40.7%) 59/118 (50%) + C-Reactive Protein Measurement + Low 55/122 (45.1%) 44/125 (35.2%) 50/120 (41.7%) + High 55/115 (47.8%) 47/115 (40.9%) 44/114 (38.6%) + IMMUNOLOGY + Immunoglobulin A Measurement + Low 51/120 (42.5%) 61/119 (51.3%) 50/120 (41.7%) + High 58/119 (48.7%) 54/123 (43.9%) 45/119 (37.8%) + diff --git a/tests/testthat/_snaps/table_lbt05.md b/tests/testthat/_snaps/table_lbt05.md new file mode 100644 index 0000000000..2ba4220b11 --- /dev/null +++ b/tests/testthat/_snaps/table_lbt05.md @@ -0,0 +1,89 @@ +# LBT05 variant 1 is produced correctly + + Code + res + Output + Laboratory Test ARM A ARM B ARM C + Direction of abnormality (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————— + ALT (n) 134 134 132 + Low + Any Abnormality 0 0 0 + CRP (n) 134 134 132 + Low + Single, not last 2 (1.5%) 0 0 + Last or replicated 10 (7.5%) 7 (5.2%) 7 (5.3%) + Any Abnormality 12 (9%) 7 (5.2%) 7 (5.3%) + High + Single, not last 1 (0.7%) 2 (1.5%) 1 (0.8%) + Last or replicated 10 (7.5%) 9 (6.7%) 12 (9.1%) + Any Abnormality 11 (8.2%) 11 (8.2%) 13 (9.8%) + IGA (n) 134 134 132 + Low + Single, not last 2 (1.5%) 1 (0.7%) 1 (0.8%) + Last or replicated 5 (3.7%) 8 (6%) 10 (7.6%) + Any Abnormality 7 (5.2%) 9 (6.7%) 11 (8.3%) + High + Single, not last 0 0 1 (0.8%) + Last or replicated 4 (3%) 9 (6.7%) 5 (3.8%) + Any Abnormality 4 (3%) 9 (6.7%) 6 (4.5%) + +# LBT05 variant 2 is produced correctly + + Code + res + Output + Laboratory Test ARM A ARM B ARM C + Direction of abnormality (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————— + ALT (n) 134 134 132 + Low + Single, not last 0 0 0 + Last or replicated 0 0 0 + Any Abnormality 0 0 0 + CRP (n) 134 134 132 + Low + Single, not last 2 (1.5%) 0 0 + Last or replicated 10 (7.5%) 7 (5.2%) 7 (5.3%) + Any Abnormality 12 (9%) 7 (5.2%) 7 (5.3%) + High + Single, not last 1 (0.7%) 2 (1.5%) 1 (0.8%) + Last or replicated 10 (7.5%) 9 (6.7%) 12 (9.1%) + Any Abnormality 11 (8.2%) 11 (8.2%) 13 (9.8%) + IGA (n) 134 134 132 + Low + Single, not last 2 (1.5%) 1 (0.7%) 1 (0.8%) + Last or replicated 5 (3.7%) 8 (6%) 10 (7.6%) + Any Abnormality 7 (5.2%) 9 (6.7%) 11 (8.3%) + High + Single, not last 0 0 1 (0.8%) + Last or replicated 4 (3%) 9 (6.7%) 5 (3.8%) + Any Abnormality 4 (3%) 9 (6.7%) 6 (4.5%) + +# LBT05 variant 4 is produced correctly + + Code + res + Output + Laboratory Test ARM A ARM B ARM C + Direction of abnormality (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————— + CRP (n) 134 134 132 + Low + Single, not last 2 (1.5%) 0 0 + Last or replicated 10 (7.5%) 7 (5.2%) 7 (5.3%) + Any Abnormality 12 (9%) 7 (5.2%) 7 (5.3%) + High + Single, not last 1 (0.7%) 2 (1.5%) 1 (0.8%) + Last or replicated 10 (7.5%) 9 (6.7%) 12 (9.1%) + Any Abnormality 11 (8.2%) 11 (8.2%) 13 (9.8%) + IGA (n) 134 134 132 + Low + Single, not last 2 (1.5%) 1 (0.7%) 1 (0.8%) + Last or replicated 5 (3.7%) 8 (6%) 10 (7.6%) + Any Abnormality 7 (5.2%) 9 (6.7%) 11 (8.3%) + High + Single, not last 0 0 1 (0.8%) + Last or replicated 4 (3%) 9 (6.7%) 5 (3.8%) + Any Abnormality 4 (3%) 9 (6.7%) 6 (4.5%) + diff --git a/tests/testthat/_snaps/table_lbt06.md b/tests/testthat/_snaps/table_lbt06.md new file mode 100644 index 0000000000..ddde048e17 --- /dev/null +++ b/tests/testthat/_snaps/table_lbt06.md @@ -0,0 +1,55 @@ +# LBT06 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————————————— + Alanine Aminotransferase Measurement + WEEK 1 DAY 8 + Low + Not low baseline status 10/124 (8.1%) 8/122 (6.6%) 6/117 (5.1%) + Low baseline status 2/10 (20%) 0/12 0/15 + Total 12/134 (9%) 8/134 (6%) 6/132 (4.5%) + High + Not high baseline status 10/121 (8.3%) 11/118 (9.3%) 11/118 (9.3%) + High baseline status 1/13 (7.7%) 2/16 (12.5%) 1/14 (7.1%) + Total 11/134 (8.2%) 13/134 (9.7%) 12/132 (9.1%) + WEEK 2 DAY 15 + Low + Not low baseline status 13/124 (10.5%) 8/122 (6.6%) 13/117 (11.1%) + Low baseline status 2/10 (20%) 0/12 0/15 + Total 15/134 (11.2%) 8/134 (6%) 13/132 (9.8%) + High + Not high baseline status 8/121 (6.6%) 13/118 (11%) 15/118 (12.7%) + High baseline status 1/13 (7.7%) 2/16 (12.5%) 1/14 (7.1%) + Total 9/134 (6.7%) 15/134 (11.2%) 16/132 (12.1%) + WEEK 3 DAY 22 + Low + Not low baseline status 12/124 (9.7%) 13/122 (10.7%) 6/117 (5.1%) + Low baseline status 1/10 (10%) 2/12 (16.7%) 3/15 (20%) + Total 13/134 (9.7%) 15/134 (11.2%) 9/132 (6.8%) + High + Not high baseline status 12/121 (9.9%) 16/118 (13.6%) 14/118 (11.9%) + High baseline status 1/13 (7.7%) 2/16 (12.5%) 0/14 + Total 13/134 (9.7%) 18/134 (13.4%) 14/132 (10.6%) + WEEK 4 DAY 29 + Low + Not low baseline status 10/124 (8.1%) 13/122 (10.7%) 10/117 (8.5%) + Low baseline status 0/10 2/12 (16.7%) 0/15 + Total 10/134 (7.5%) 15/134 (11.2%) 10/132 (7.6%) + High + Not high baseline status 12/121 (9.9%) 8/118 (6.8%) 18/118 (15.3%) + High baseline status 3/13 (23.1%) 2/16 (12.5%) 1/14 (7.1%) + Total 15/134 (11.2%) 10/134 (7.5%) 19/132 (14.4%) + WEEK 5 DAY 36 + Low + Not low baseline status 14/124 (11.3%) 15/122 (12.3%) 10/117 (8.5%) + Low baseline status 2/10 (20%) 3/12 (25%) 1/15 (6.7%) + Total 16/134 (11.9%) 18/134 (13.4%) 11/132 (8.3%) + High + Not high baseline status 16/121 (13.2%) 9/118 (7.6%) 10/118 (8.5%) + High baseline status 1/13 (7.7%) 2/16 (12.5%) 0/14 + Total 17/134 (12.7%) 11/134 (8.2%) 10/132 (7.6%) + diff --git a/tests/testthat/_snaps/table_lbt07.md b/tests/testthat/_snaps/table_lbt07.md new file mode 100644 index 0000000000..0e9f84a4c6 --- /dev/null +++ b/tests/testthat/_snaps/table_lbt07.md @@ -0,0 +1,36 @@ +# LBT07 is produced correctly + + Code + res + Output + PARAM ARM A ARM B ARM C + Direction of abnormality (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————— + Alanine Aminotransferase Measurement (n) 134 134 132 + LOW + 1 14 (10.4%) 15 (11.2%) 10 (7.6%) + 2 13 (9.7%) 18 (13.4%) 11 (8.3%) + 3 20 (14.9%) 12 (9%) 10 (7.6%) + 4 7 (5.2%) 8 (6%) 10 (7.6%) + Any 54 (40.3%) 53 (39.6%) 41 (31.1%) + C-Reactive Protein Measurement (n) 134 134 132 + LOW + 1 16 (11.9%) 19 (14.2%) 15 (11.4%) + 2 21 (15.7%) 13 (9.7%) 16 (12.1%) + 3 12 (9%) 9 (6.7%) 18 (13.6%) + 4 11 (8.2%) 7 (5.2%) 5 (3.8%) + Any 60 (44.8%) 48 (35.8%) 54 (40.9%) + HIGH + 1 17 (12.7%) 15 (11.2%) 9 (6.8%) + 2 15 (11.2%) 16 (11.9%) 13 (9.8%) + 3 16 (11.9%) 12 (9%) 14 (10.6%) + 4 12 (9%) 12 (9%) 10 (7.6%) + Any 60 (44.8%) 55 (41%) 46 (34.8%) + Immunoglobulin A Measurement (n) 134 134 132 + HIGH + 1 25 (18.7%) 14 (10.4%) 13 (9.8%) + 2 14 (10.4%) 20 (14.9%) 16 (12.1%) + 3 12 (9%) 13 (9.7%) 17 (12.9%) + 4 11 (8.2%) 13 (9.7%) 4 (3%) + Any 62 (46.3%) 60 (44.8%) 50 (37.9%) + diff --git a/tests/testthat/_snaps/table_lbt08.md b/tests/testthat/_snaps/table_lbt08.md new file mode 100644 index 0000000000..dbca4d22ea --- /dev/null +++ b/tests/testthat/_snaps/table_lbt08.md @@ -0,0 +1,36 @@ +# LBT08 produce correctly + + Code + res + Output + PARAMCD ARM A ARM B ARM C + GRADDR (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————— + ALT + High + 1 16/121 (13.2%) 13/117 (11.1%) 17/117 (14.5%) + 2 14/125 (11.2%) 12/121 (9.9%) 17/120 (14.2%) + 3 9/129 (7%) 15/125 (12%) 13/124 (10.5%) + 4 12/131 (9.2%) 11/130 (8.5%) 13/129 (10.1%) + Any 51/131 (38.9%) 51/130 (39.2%) 60/129 (46.5%) + Low + 1 13/124 (10.5%) 12/121 (9.9%) 9/117 (7.7%) + 2 13/127 (10.2%) 17/127 (13.4%) 11/124 (8.9%) + 3 19/129 (14.7%) 12/128 (9.4%) 10/128 (7.8%) + 4 7/131 (5.3%) 7/131 (5.3%) 10/132 (7.6%) + Any 52/131 (39.7%) 48/131 (36.6%) 40/132 (30.3%) + CRP + Low + 1 14/122 (11.5%) 17/125 (13.6%) 13/120 (10.8%) + 2 21/124 (16.9%) 12/130 (9.2%) 16/125 (12.8%) + 3 12/129 (9.3%) 9/131 (6.9%) 17/126 (13.5%) + 4 10/131 (7.6%) 7/133 (5.3%) 4/127 (3.1%) + Any 57/131 (43.5%) 45/133 (33.8%) 50/127 (39.4%) + IGA + High + 1 24/118 (20.3%) 12/120 (10%) 13/119 (10.9%) + 2 13/120 (10.8%) 19/124 (15.3%) 13/125 (10.4%) + 3 11/124 (8.9%) 10/128 (7.8%) 17/128 (13.3%) + 4 11/129 (8.5%) 13/130 (10%) 4/130 (3.1%) + Any 59/129 (45.7%) 54/130 (41.5%) 47/130 (36.2%) + diff --git a/tests/testthat/_snaps/table_lbt14.md b/tests/testthat/_snaps/table_lbt14.md new file mode 100644 index 0000000000..0fcc6b6e9d --- /dev/null +++ b/tests/testthat/_snaps/table_lbt14.md @@ -0,0 +1,187 @@ +# LBT14 variant 1: HIGH works as expected + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————— + ALT + Not High (n) 121 118 118 + Not High 72 (59.5%) 70 (59.3%) 59 (50.0%) + 1 16 (13.2%) 13 (11.0%) 17 (14.4%) + 2 13 (10.7%) 12 (10.2%) 18 (15.3%) + 3 9 (7.4%) 14 (11.9%) 12 (10.2%) + 4 11 (9.1%) 9 (7.6%) 12 (10.2%) + 1 (n) 4 4 3 + Not High 1 (25.0%) 1 (25.0%) 2 (66.7%) + 1 1 (25.0%) 0 0 + 2 1 (25.0%) 0 0 + 3 0 1 (25.0%) 1 (33.3%) + 4 1 (25.0%) 2 (50.0%) 0 + 2 (n) 4 4 4 + Not High 3 (75.0%) 3 (75.0%) 3 (75.0%) + 1 0 1 (25.0%) 1 (25.0%) + 2 1 (25.0%) 0 0 + 3 (n) 2 5 5 + Not High 2 (100%) 2 (40.0%) 4 (80.0%) + 1 0 2 (40.0%) 0 + 2 0 1 (20.0%) 0 + 4 0 0 1 (20.0%) + 4 (n) 3 3 2 + Not High 1 (33.3%) 2 (66.7%) 2 (100%) + 1 1 (33.3%) 0 0 + 3 1 (33.3%) 1 (33.3%) 0 + +# LBT14 variant 2: LOW works as expected + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————— + ALT + Not Low (n) 124 122 117 + Not Low 74 (59.7%) 76 (62.3%) 80 (68.4%) + 1 13 (10.5%) 12 (9.8%) 9 (7.7%) + 2 13 (10.5%) 16 (13.1%) 11 (9.4%) + 3 17 (13.7%) 11 (9.0%) 9 (7.7%) + 4 7 (5.6%) 7 (5.7%) 8 (6.8%) + 1 (n) 3 6 7 + Not Low 0 2 (33.3%) 5 (71.4%) + 1 1 (33.3%) 2 (33.3%) 0 + 2 0 1 (16.7%) 0 + 3 2 (66.7%) 1 (16.7%) 0 + 4 0 0 2 (28.6%) + 2 (n) 2 1 4 + Not Low 2 (100%) 0 3 (75.0%) + 2 0 1 (100%) 0 + 3 0 0 1 (25.0%) + 3 (n) 2 3 4 + Not Low 2 (100%) 2 (66.7%) 3 (75.0%) + 1 0 1 (33.3%) 1 (25.0%) + 4 (n) 3 2 0 + Not Low 2 (66.7%) 1 (50.0%) 0 + 3 1 (33.3%) 0 0 + 4 0 1 (50.0%) 0 + +# LBT14 variant 3: LOW without baseline missing works as expected + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————— + ALT + Not Low (n) 124 122 117 + Not Low 74 (59.7%) 76 (62.3%) 80 (68.4%) + 1 13 (10.5%) 12 (9.8%) 9 (7.7%) + 2 13 (10.5%) 16 (13.1%) 11 (9.4%) + 3 17 (13.7%) 11 (9.0%) 9 (7.7%) + 4 7 (5.6%) 7 (5.7%) 8 (6.8%) + 1 (n) 3 6 7 + Not Low 0 2 (33.3%) 5 (71.4%) + 1 1 (33.3%) 2 (33.3%) 0 + 2 0 1 (16.7%) 0 + 3 2 (66.7%) 1 (16.7%) 0 + 4 0 0 2 (28.6%) + 2 (n) 2 1 4 + Not Low 2 (100%) 0 3 (75.0%) + 2 0 1 (100%) 0 + 3 0 0 1 (25.0%) + 3 (n) 2 3 4 + Not Low 2 (100%) 2 (66.7%) 3 (75.0%) + 1 0 1 (33.3%) 1 (25.0%) + 4 (n) 3 2 0 + Not Low 2 (66.7%) 1 (50.0%) 0 + 3 1 (33.3%) 0 0 + 4 0 1 (50.0%) 0 + +# LBT14 variant 4: LOW and force 1 missing both baseline and post-baseline, then force the missing baseline as 0 as expected + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————— + ALT + Not Low (n) 124 122 117 + Not Low 74 (59.7%) 76 (62.3%) 80 (68.4%) + 1 13 (10.5%) 12 (9.8%) 9 (7.7%) + 2 13 (10.5%) 16 (13.1%) 11 (9.4%) + 3 16 (12.9%) 11 (9.0%) 9 (7.7%) + 4 7 (5.6%) 7 (5.7%) 8 (6.8%) + Missing 1 (0.8%) 0 0 + 1 (n) 3 6 7 + Not Low 0 2 (33.3%) 5 (71.4%) + 1 1 (33.3%) 2 (33.3%) 0 + 2 0 1 (16.7%) 0 + 3 2 (66.7%) 1 (16.7%) 0 + 4 0 0 2 (28.6%) + 2 (n) 2 1 4 + Not Low 2 (100%) 0 3 (75.0%) + 2 0 1 (100%) 0 + 3 0 0 1 (25.0%) + 3 (n) 2 3 4 + Not Low 2 (100%) 2 (66.7%) 3 (75.0%) + 1 0 1 (33.3%) 1 (25.0%) + 4 (n) 3 2 0 + Not Low 2 (66.7%) 1 (50.0%) 0 + 3 1 (33.3%) 0 0 + 4 0 1 (50.0%) 0 + +# LBT14 variant 5: HIGH with fillings works as expected + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————— + ALT + Not High (n) 121 118 118 + Not High 72 (59.5%) 70 (59.3%) 59 (50.0%) + 1 16 (13.2%) 13 (11.0%) 17 (14.4%) + 2 13 (10.7%) 12 (10.2%) 18 (15.3%) + 3 9 (7.4%) 14 (11.9%) 12 (10.2%) + 4 11 (9.1%) 9 (7.6%) 12 (10.2%) + Missing 0 0 0 + 1 (n) 4 4 3 + Not High 1 (25.0%) 1 (25.0%) 2 (66.7%) + 1 1 (25.0%) 0 0 + 2 1 (25.0%) 0 0 + 3 0 1 (25.0%) 1 (33.3%) + 4 1 (25.0%) 2 (50.0%) 0 + Missing 0 0 0 + 2 (n) 4 4 4 + Not High 3 (75.0%) 3 (75.0%) 3 (75.0%) + 1 0 1 (25.0%) 1 (25.0%) + 2 1 (25.0%) 0 0 + 3 0 0 0 + 4 0 0 0 + Missing 0 0 0 + 3 (n) 2 5 5 + Not High 2 (100%) 2 (40.0%) 4 (80.0%) + 1 0 2 (40.0%) 0 + 2 0 1 (20.0%) 0 + 3 0 0 0 + 4 0 0 1 (20.0%) + Missing 0 0 0 + 4 (n) 3 3 2 + Not High 1 (33.3%) 2 (66.7%) 2 (100%) + 1 1 (33.3%) 0 0 + 2 0 0 0 + 3 1 (33.3%) 1 (33.3%) 0 + 4 0 0 0 + Missing 0 0 0 + Missing (n) 0 0 0 + Not High 0 0 0 + 1 0 0 0 + 2 0 0 0 + 3 0 0 0 + 4 0 0 0 + Missing 0 0 0 + diff --git a/tests/testthat/_snaps/table_lgrt02.md b/tests/testthat/_snaps/table_lgrt02.md new file mode 100644 index 0000000000..efb8c8b400 --- /dev/null +++ b/tests/testthat/_snaps/table_lgrt02.md @@ -0,0 +1,110 @@ +# LGRT02 without interaction term is produced correctly + + Code + res + Output + Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Planned Arm Code 2 0.0346 + Reference ARM A, n = 134 + ARM B, n = 134 1 -2.162 1.084 0.12 (0.01, 0.96) 0.0461 + ARM C, n = 132 1 -0.090 1.426 0.91 (0.06, 14.97) 0.9499 + Sex + Reference M, n = 169 + F, n = 231 1 0.364 0.701 1.44 (0.36, 5.69) 0.6032 + Race 5 0.9685 + Reference AMERICAN INDIAN OR ALASKA NATIVE, n = 25 + ASIAN, n = 208 1 -16.246 2017.122 0.00 (0.00, >999.99) 0.9936 + BLACK OR AFRICAN AMERICAN, n = 91 1 -15.205 2017.122 0.00 (0.00, >999.99) 0.9940 + WHITE, n = 74 1 -15.955 2017.122 0.00 (0.00, >999.99) 0.9937 + MULTIPLE, n = 1 1 -0.363 10941.553 0.70 (0.00, >999.99) 1.0000 + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER, n = 1 1 1.036 10941.553 2.82 (0.00, >999.99) 0.9999 + Age + Age 1 0.071 0.053 1.07 (0.97, 1.19) 0.1866 + +# LGRT02 with categorical interaction is produced correctly + + Code + res + Output + Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Age + Age 1 0.067 0.054 1.07 (0.96, 1.19) 0.2084 + Planned Arm Code 2 0.4882 + Reference ARM A, n = 134 + ARM B, n = 134 1 -17.850 2362.767 0.9940 + Sex + F 0.23 (0.02, 2.11) + M 0.00 (0.00, >999.99) + ARM C, n = 132 1 -16.442 2362.767 0.9944 + Sex + F >999.99 (0.00, >999.99) + M 0.00 (0.00, >999.99) + Sex + Reference M, n = 169 + F, n = 231 1 -16.044 2362.767 0.9946 + Planned Arm Code + ARM A 0.00 (0.00, >999.99) + ARM B 1.39 (0.29, 6.59) + ARM C >999.99 (0.00, >999.99) + Interaction of Planned Arm Code * Sex 2 0.9999 + Reference ARM A or M, n = 248 + ARM B * F, n = 82 1 16.373 2362.767 0.9945 + ARM C * F, n = 70 1 32.492 3156.732 0.9918 + +# LGRT02 with continuous interaction is produced correctly + + Code + res + Output + Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 95% CI p-value + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Sex + Reference M, n = 169 + F, n = 231 1 0.381 0.710 1.46 (0.36, 5.88) 0.5915 + Planned Arm Code 2 0.2768 + Reference ARM A, n = 134 + ARM B, n = 134 1 20.020 13.714 0.1443 + Age + 18 113.59 (0.14, >999.99) + 65 0.00 (<0.01, >999.99) + ARM C, n = 132 1 15.622 14.810 0.2915 + Age + 18 64.74 (0.03, >999.99) + 65 0.00 (<0.01, >999.99) + Age + Age 1 0.877 0.581 0.1309 + Planned Arm Code + ARM A 2.40 (0.77, 7.50) + ARM B 1.03 (0.93, 1.14) + ARM C 1.27 (0.84, 1.93) + Interaction of Planned Arm Code * Age 2 0.2213 + Reference ARM A, n = 134 + ARM B, n = 134 1 -0.849 0.583 0.1449 + ARM C, n = 132 1 -0.636 0.618 0.3034 + +# LGRT02 with setting values indicating an event and custom alpha level is produced correctly + + Code + res + Output + Degrees of Freedom Parameter Estimate Standard Error Odds Ratio Wald 90% CI p-value + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Planned Arm Code 2 0.0346 + Reference ARM A, n = 134 + ARM B, n = 134 1 2.162 1.084 8.69 (1.46, 51.66) 0.0461 + ARM C, n = 132 1 0.090 1.426 1.09 (0.10, 11.43) 0.9499 + Sex + Reference M, n = 169 + F, n = 231 1 -0.364 0.701 0.69 (0.22, 2.20) 0.6032 + Age + Age 1 -0.071 0.053 0.93 (0.85, 1.02) 0.1866 + Race 5 0.9685 + Reference AMERICAN INDIAN OR ALASKA NATIVE, n = 25 + ASIAN, n = 208 1 16.246 2017.122 >999.99 (0.00, >999.99) 0.9936 + BLACK OR AFRICAN AMERICAN, n = 91 1 15.205 2017.122 >999.99 (0.00, >999.99) 0.9940 + WHITE, n = 74 1 15.955 2017.122 >999.99 (0.00, >999.99) 0.9937 + MULTIPLE, n = 1 1 0.363 10941.553 1.44 (0.00, >999.99) 1.0000 + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER, n = 1 1 -1.036 10941.553 0.35 (0.00, >999.99) 0.9999 + diff --git a/tests/testthat/_snaps/table_mht01.md b/tests/testthat/_snaps/table_mht01.md new file mode 100644 index 0000000000..98c278e925 --- /dev/null +++ b/tests/testthat/_snaps/table_mht01.md @@ -0,0 +1,109 @@ +# MHT01 variant 1 is produced accurately + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one event 122 (91%) 123 (91.8%) 120 (90.9%) + Total number of events 609 622 703 + cl A + Total number of patients with at least one event 78 (58.2%) 75 (56%) 89 (67.4%) + Total number of events 132 130 160 + trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) + trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) + cl B + Total number of patients with at least one event 96 (71.6%) 89 (66.4%) 97 (73.5%) + Total number of events 185 198 205 + trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) + trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) + trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl C + Total number of patients with at least one event 67 (50%) 75 (56%) 79 (59.8%) + Total number of events 103 116 129 + trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) + trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl D + Total number of patients with at least one event 96 (71.6%) 90 (67.2%) 98 (74.2%) + Total number of events 189 178 209 + trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) + trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) + trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) + +# MHT01 variant 2 is produced accurately + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one event 0 0 1 (0.8%) + Total number of events 0 0 1 + cl D + Total number of patients with at least one event 0 0 1 (0.8%) + Total number of events 0 0 1 + trm D_2/3 0 0 1 (0.8%) + +# MHT01 variant 3 is produced accurately + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one event 122 (91%) 123 (91.8%) 120 (90.9%) + cl A + Total number of patients with at least one event 78 (58.2%) 75 (56%) 89 (67.4%) + trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) + trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) + cl B + Total number of patients with at least one event 96 (71.6%) 89 (66.4%) 97 (73.5%) + trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) + trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) + trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) + cl C + Total number of patients with at least one event 67 (50%) 75 (56%) 79 (59.8%) + trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) + trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) + cl D + Total number of patients with at least one event 96 (71.6%) 90 (67.2%) 98 (74.2%) + trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) + trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) + trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) + +# MHT01 variant 5 is produced accurately + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one event 122 (91%) 123 (91.8%) 120 (90.9%) 365 (91.2%) + Number of events 609 622 703 1934 + cl A + Total number of patients with at least one event 78 (58.2%) 75 (56%) 89 (67.4%) 242 (60.5%) + Number of events 132 130 160 422 + trm A_1/2 50 (37.3%) 45 (33.6%) 63 (47.7%) 158 (39.5%) + trm A_2/2 48 (35.8%) 48 (35.8%) 50 (37.9%) 146 (36.5%) + cl B + Total number of patients with at least one event 96 (71.6%) 89 (66.4%) 97 (73.5%) 282 (70.5%) + Number of events 185 198 205 588 + trm B_1/3 47 (35.1%) 49 (36.6%) 43 (32.6%) 139 (34.8%) + trm B_2/3 49 (36.6%) 44 (32.8%) 52 (39.4%) 145 (36.2%) + trm B_3/3 48 (35.8%) 54 (40.3%) 51 (38.6%) 153 (38.2%) + cl C + Total number of patients with at least one event 67 (50%) 75 (56%) 79 (59.8%) 221 (55.2%) + Number of events 103 116 129 348 + trm C_1/2 43 (32.1%) 46 (34.3%) 43 (32.6%) 132 (33.0%) + trm C_2/2 35 (26.1%) 48 (35.8%) 55 (41.7%) 138 (34.5%) + cl D + Total number of patients with at least one event 96 (71.6%) 90 (67.2%) 98 (74.2%) 284 (71%) + Number of events 189 178 209 576 + trm D_1/3 50 (37.3%) 42 (31.3%) 51 (38.6%) 143 (35.8%) + trm D_2/3 48 (35.8%) 42 (31.3%) 50 (37.9%) 140 (35.0%) + trm D_3/3 47 (35.1%) 58 (43.3%) 57 (43.2%) 162 (40.5%) + diff --git a/tests/testthat/_snaps/table_onct05.md b/tests/testthat/_snaps/table_onct05.md new file mode 100644 index 0000000000..5b8ffd0121 --- /dev/null +++ b/tests/testthat/_snaps/table_onct05.md @@ -0,0 +1,65 @@ +# ONCT05 variant 1 (Objective Response Rate by Subgroup) is produced correctly + + Code + res + Output + Baseline Risk Factors B: Placebo A: Drug X + Total n n Response (%) n Response (%) Odds Ratio 95% CI + ———————————————————————————————————————————————————————————————————————————————————————————————————————— + All Patients 200 100 71.0% 100 90.0% 3.68 (1.68, 8.04) + Sex + F 120 62 64.5% 58 91.4% 5.83 (2.03, 16.73) + M 80 38 81.6% 42 88.1% 1.67 (0.48, 5.79) + Stratification Factor 2 + S1 105 48 70.8% 57 89.5% 3.50 (1.22, 10.00) + S2 95 52 71.2% 43 90.7% 3.95 (1.20, 13.01) + +# ONCT05 variant 2 (Specifying class variables) is produced correctly + + Code + res + Output + Baseline Risk Factors B: Placebo A: Drug X + Total n n Response (%) n Response (%) Odds Ratio 95% CI + —————————————————————————————————————————————————————————————————————————————————————————————————————————— + All Patients 200 100 71.0% 100 90.0% 3.68 (1.68, 8.04) + Sex + M 80 38 81.6% 42 88.1% 1.67 (0.48, 5.79) + F 120 62 64.5% 58 91.4% 5.83 (2.03, 16.73) + Stratification Factor 1 + C 72 36 72.2% 36 94.4% 6.54 (1.32, 32.44) + B 71 35 74.3% 36 77.8% 1.21 (0.41, 3.61) + A 57 29 65.5% 28 100.0% >999.99 (0.00, >999.99) + +# ONCT05 variant 3 (selecting columns and changing the alpha level) is produced correctly + + Code + res + Output + Baseline Risk Factors + Total n Odds Ratio 90% CI p-value (Chi-Squared Test) + ——————————————————————————————————————————————————————————————————————————————————————————— + All Patients 200 3.68 (1.91, 7.09) 0.0007 + Sex + F 120 5.83 (2.41, 14.12) 0.0004 + M 80 1.67 (0.59, 4.74) 0.4150 + Stratification Factor 2 + S1 105 3.50 (1.45, 8.45) 0.0154 + S2 95 3.95 (1.45, 10.74) 0.0178 + +# ONCT05 variant 4 (setting values indicating response) is produced correctly + + Code + res + Output + Baseline Risk Factors B: Placebo A: Drug X + Total n n Response (%) n Response (%) Odds Ratio 95% CI + —————————————————————————————————————————————————————————————————————————————————————————————————————————— + All Patients 200 100 95.0% 100 99.0% 5.21 (0.60, 45.43) + Sex + F 120 62 96.8% 58 98.3% 1.90 (0.17, 21.53) + M 80 38 92.1% 42 100.0% >999.99 (0.00, >999.99) + Stratification Factor 2 + S1 105 48 97.9% 57 100.0% >999.99 (0.00, >999.99) + S2 95 52 92.3% 43 97.7% 3.50 (0.38, 32.55) + diff --git a/tests/testthat/_snaps/table_pdt01.md b/tests/testthat/_snaps/table_pdt01.md new file mode 100644 index 0000000000..4e4890c826 --- /dev/null +++ b/tests/testthat/_snaps/table_pdt01.md @@ -0,0 +1,37 @@ +# PDT01 is produced correctly + + Code + res + Output + Protocol Deviation Coded Term A: Drug X B: Placebo C: Combination + Protocol Deviation Term (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one major protocol deviation 22 (16.4%) 23 (17.2%) 13 (9.8%) + Total number of major protocol deviations 40 42 21 + EXCLUSION CRITERIA + Active or untreated or other excluded cns metastases 5 (3.7%) 3 (2.2%) 0 + Pregnancy criteria 2 (1.5%) 4 (3.0%) 0 + History of other malignancies within the last 5 years 3 (2.2%) 2 (1.5%) 0 + Uncontrolled concurrent condition 3 (2.2%) 1 (0.7%) 0 + Other exclusion criteria 0 0 3 (2.3%) + Received prior prohibited therapy or medication 0 2 (1.5%) 1 (0.8%) + INCLUSION CRITERIA + No signed ICF at study entry 6 (4.5%) 4 (3.0%) 0 + Ineligible cancer type or current cancer stage 6 (4.5%) 1 (0.7%) 1 (0.8%) + Inclusion lab values outside allowed limits 0 3 (2.2%) 0 + Does not meet prior therapy requirements 1 (0.7%) 0 0 + Inclusion-related test not done/out of window 0 0 1 (0.8%) + MEDICATION + Significant deviation from planned dose 3 (2.2%) 1 (0.7%) 2 (1.5%) + Received incorrect study medication 1 (0.7%) 2 (1.5%) 1 (0.8%) + Discontinued study drug for unspecified reason 1 (0.7%) 1 (0.7%) 1 (0.8%) + Dose missed or significantly out of window 2 (1.5%) 0 1 (0.8%) + Received prohibited concomitant medication 0 2 (1.5%) 0 + PROCEDURAL + Eligibility-related test not done/out of window 1 (0.7%) 6 (4.5%) 1 (0.8%) + Omission of screening tumor assessment 0 4 (3.0%) 3 (2.3%) + Missed assessment affecting safety/study outcomes 1 (0.7%) 2 (1.5%) 2 (1.5%) + Failure to sign updated ICF within two visits 2 (1.5%) 1 (0.7%) 1 (0.8%) + Missed 2 or more efficacy assessments 2 (1.5%) 0 1 (0.8%) + Omission of complete lab panel required by protocol 0 1 (0.7%) 1 (0.8%) + diff --git a/tests/testthat/_snaps/table_pdt02.md b/tests/testthat/_snaps/table_pdt02.md new file mode 100644 index 0000000000..18c3904d5f --- /dev/null +++ b/tests/testthat/_snaps/table_pdt02.md @@ -0,0 +1,16 @@ +# PDT02 is produced correctly + + Code + res + Output + Reason for Deviation A: Drug X B: Placebo C: Combination + Protocol Deviation Term (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Total number of patients with at least one major protocol deviation related to epidemic/pandemic 9 (6.7%) 2 (1.5%) 5 (3.8%) + Total number of major protocol deviations related to epidemic/pandemic 9 2 6 + Site action due to epidemic/pandemic (n) 9 2 5 + Dose missed or significantly out of window 2 (1.5%) 0 1 (0.8%) + Failure to sign updated ICF within two visits 2 (1.5%) 1 (0.7%) 1 (0.8%) + Missed 2 or more efficacy assessments 2 (1.5%) 0 1 (0.8%) + Significant deviation from planned dose 3 (2.2%) 1 (0.7%) 2 (1.5%) + diff --git a/tests/testthat/_snaps/table_pkct01.md b/tests/testthat/_snaps/table_pkct01.md new file mode 100644 index 0000000000..60a515695d --- /dev/null +++ b/tests/testthat/_snaps/table_pkct01.md @@ -0,0 +1,100 @@ +# PKCT01 is produced correctly + + Code + res + Output + n Mean SD SE CV (%) CV % Geometric Mean + ————————————————————————————————————————————————————————————————————————— + A: Drug X + Plasma Drug X + 1474 6.5 6.7 0.2 102.4 NA + Plasma Drug Y + 0 NA NA NA NA NA + Urine Drug X + 804 0.9 1.8 0.1 210.7 NA + Urine Drug Y + 804 0.9 1.8 0.1 210.7 NA + C: Combination + Plasma Drug X + 1452 6.5 6.7 0.2 103.3 NA + Plasma Drug Y + 1452 13.1 13.5 0.4 103.3 NA + Urine Drug X + 792 0.8 1.8 0.1 212.4 NA + Urine Drug Y + 792 0.8 1.8 0.1 212.4 NA + +--- + + Code + res + Output + n_blq + ——————————————————————— + A: Drug X + Plasma Drug X + 402 + Plasma Drug Y + 0 + Urine Drug X + 402 + Urine Drug Y + 402 + C: Combination + Plasma Drug X + 396 + Plasma Drug Y + 396 + Urine Drug X + 396 + Urine Drug Y + 396 + +# Specific PKCT01 features are present + + Code + res + Output + Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable + Protocol: xxxxx + Analyte: Plasma Drug X Treatment: A: Drug X + Analyte: Urine Drug X Treatment: C: Combination + Analyte: Urine Drug Y Treatment: A: Drug X + Analyte: Plasma Drug Y Treatment: C: Combination + + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Cohort/Treatment + Visit + Norminal Time from First Dose Number + of + n s Mean SD CV (%) Mean Geometric Mean CV % Geometric Mean Median Minimum Maximum + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X + Day 1 + 0 + 402 402 0 0 NE NE NE 0 0 0 + 0.5 + 134 0 12.6 1.51 12.0 12.5 12.2 12.6 9.72 15.6 + 1 + 134 0 16.2 1.63 10.0 16.1 10.1 16.2 12.6 19.9 + 1.5 + 134 0 15.6 1.46 9.3 15.6 9.3 15.5 12.3 19 + 2 + 134 0 13.4 1.35 10.1 13.4 10.0 13.3 10.8 16.5 + 3 + 134 0 8.47 1.25 14.7 8.38 15.0 8.4 5.88 10.9 + 4 + 402 0 4.79 1.01 21.2 4.69 21.9 4.79 2.7 7.09 + 8 + 402 0 0.348 0.179 51.6 0.303 58.2 0.318 0.076 0.866 + 12 + 402 0 0.0224 0.0189 84.4 0.0156 111.2 0.017 0.002 0.083 + 24 + 402 402 0 0 NE NE NE 0 0 0 + Day 2 + 48 + 402 402 0 0 NE NE NE 0 0 0 + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + NE: Not Estimable + diff --git a/tests/testthat/_snaps/table_pkpt02.md b/tests/testthat/_snaps/table_pkpt02.md new file mode 100644 index 0000000000..ad93e54795 --- /dev/null +++ b/tests/testthat/_snaps/table_pkpt02.md @@ -0,0 +1,64 @@ +# PKPT02 is produced correctly for Drug X + + Code + res + Output + PK Parameter ARM A ARM C + —————————————————————————————————————————————————————————————————————— + AUCinf obs (day*ug/mL) + n 134 132 + Mean (SD) 2.028e+02 (3.766e+01) 1.955e+02 (3.785e+01) + CV (%) 18.6 19.4 + Geometric Mean 1.994e+02 1.917e+02 + CV % Geometric Mean 18.7 20.1 + Median 1.971e+02 1.962e+02 + Min - Max 1.253e+02 - 3.110e+02 1.030e+02 - 3.145e+02 + CL obs (ml/day/kg) + n 134 132 + Mean (SD) 5.043e+00 (1.041e+00) 5.009e+00 (9.846e-01) + CV (%) 20.6 19.7 + Geometric Mean 4.929e+00 4.907e+00 + CV % Geometric Mean 22.4 21.1 + Median 5.078e+00 4.969e+00 + Min - Max 2.255e+00 - 7.395e+00 2.102e+00 - 7.489e+00 + Cmax (ug/mL) + n 134 132 + Mean (SD) 3.025e+01 (6.239e+00) 3.004e+01 (5.457e+00) + CV (%) 20.6 18.2 + Geometric Mean 2.961e+01 2.954e+01 + CV % Geometric Mean 21.0 18.9 + Median 2.986e+01 2.977e+01 + Min - Max 1.753e+01 - 4.871e+01 1.585e+01 - 4.757e+01 + +# PKPT02 is produced correctly for Drug Y + + Code + res + Output + PK Parameter ARM C + —————————————————————————————————————————————— + AUCinf obs (day*ug/mL) + n 132 + Mean (SD) 1.986e+02 (3.792e+01) + CV (%) 19.1 + Geometric Mean 1.952e+02 + CV % Geometric Mean 18.9 + Median 1.953e+02 + Min - Max 1.264e+02 - 3.183e+02 + CL obs (ml/day/kg) + n 132 + Mean (SD) 4.955e+00 (8.951e-01) + CV (%) 18.1 + Geometric Mean 4.873e+00 + CV % Geometric Mean 18.7 + Median 4.936e+00 + Min - Max 2.987e+00 - 7.211e+00 + Cmax (ug/mL) + n 132 + Mean (SD) 2.990e+01 (5.550e+00) + CV (%) 18.6 + Geometric Mean 2.935e+01 + CV % Geometric Mean 20.1 + Median 2.969e+01 + Min - Max 1.406e+01 - 4.345e+01 + diff --git a/tests/testthat/_snaps/table_pkpt03.md b/tests/testthat/_snaps/table_pkpt03.md new file mode 100644 index 0000000000..ce672c2c7f --- /dev/null +++ b/tests/testthat/_snaps/table_pkpt03.md @@ -0,0 +1,49 @@ +# PKPT03 Drug X is produced correctly + + Code + res + Output + Summary of Plasma PK Parameter by Treatment Arm, PK Population + Analyte: Plasma Drug X + Visit: CYCLE 1 DAY 1 + + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Arm + PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ARM A + AUCinf obs (day*ug/mL) + 134 203 37.7 18.6 199 18.7 197 125 311 + CL obs (ml/day/kg) + 134 5.04 1.04 20.6 4.93 22.4 5.08 2.25 7.39 + Cmax (ug/mL) + 134 30.2 6.24 20.6 29.6 21.0 29.9 17.5 48.7 + ARM C + AUCinf obs (day*ug/mL) + 132 195 37.8 19.4 192 20.1 196 103 315 + CL obs (ml/day/kg) + 132 5.01 0.985 19.7 4.91 21.1 4.97 2.1 7.49 + Cmax (ug/mL) + 132 30 5.46 18.2 29.5 18.9 29.8 15.9 47.6 + +# PKPT03 Drug Y is produced correctly + + Code + res + Output + Summary of Plasma PK Parameter by Treatment Arm, PK Population + Analyte: Plasma Drug Y + Visit: CYCLE 1 DAY 1 + + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Arm + PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ARM C + AUCinf obs (day*ug/mL) + 132 199 37.9 19.1 195 18.9 195 126 318 + CL obs (ml/day/kg) + 132 4.96 0.895 18.1 4.87 18.7 4.94 2.99 7.21 + Cmax (ug/mL) + 132 29.9 5.55 18.6 29.4 20.1 29.7 14.1 43.4 + diff --git a/tests/testthat/_snaps/table_pkpt04.md b/tests/testthat/_snaps/table_pkpt04.md new file mode 100644 index 0000000000..39de3adfca --- /dev/null +++ b/tests/testthat/_snaps/table_pkpt04.md @@ -0,0 +1,80 @@ +# PKPT04 is produced correctly for Drug X + + Code + res + Output + PK Parameter ARM A ARM C + ————————————————————————————————————————————————————————————————————— + Ae (mg) + n 268 264 + Mean (SD) 1.551e+00 (3.385e-01) 1.535e+00 (2.978e-01) + CV (%) 21.8 19.4 + Geometric Mean 1.513e+00 1.505e+00 + CV % Geometric Mean 23.0 20.3 + Median 1.547e+00 1.547e+00 + Min - Max 7.021e-01 - 2.464e+00 8.502e-01 - 2.208e+00 + CLR (L/hr) + n 134 132 + Mean (SD) 4.918e-02 (9.611e-03) 5.024e-02 (1.050e-02) + CV (%) 19.5 20.9 + Geometric Mean 4.818e-02 4.913e-02 + CV % Geometric Mean 21.0 21.9 + Median 4.909e-02 4.984e-02 + Min - Max 2.488e-02 - 7.511e-02 2.505e-02 - 8.560e-02 + Fe (%) + n 268 264 + Mean (SD) 1.571e+01 (3.348e+00) 1.609e+01 (3.103e+00) + CV (%) 21.3 19.3 + Geometric Mean 1.534e+01 1.578e+01 + CV % Geometric Mean 22.2 20.2 + Median 1.577e+01 1.604e+01 + Min - Max 8.147e+00 - 2.452e+01 8.503e+00 - 2.443e+01 + RENALCLD (L/hr/mg) + n 134 132 + Mean (SD) 4.873e-03 (9.654e-04) 5.110e-03 (9.339e-04) + CV (%) 19.8 18.3 + Geometric Mean 4.772e-03 5.019e-03 + CV % Geometric Mean 21.2 19.7 + Median 4.967e-03 5.151e-03 + Min - Max 2.385e-03 - 7.258e-03 2.356e-03 - 7.407e-03 + +# PKPT04 is produced correctly for Drug Y + + Code + res + Output + PK Parameter ARM C + ————————————————————————————————————————————— + Ae (mg) + n 264 + Mean (SD) 1.598e+00 (3.154e-01) + CV (%) 19.7 + Geometric Mean 1.565e+00 + CV % Geometric Mean 21.4 + Median 1.603e+00 + Min - Max 8.574e-01 - 2.257e+00 + CLR (L/hr) + n 132 + Mean (SD) 4.966e-02 (1.009e-02) + CV (%) 20.3 + Geometric Mean 4.857e-02 + CV % Geometric Mean 22.0 + Median 4.912e-02 + Min - Max 1.839e-02 - 7.761e-02 + Fe (%) + n 264 + Mean (SD) 1.583e+01 (3.077e+00) + CV (%) 19.4 + Geometric Mean 1.552e+01 + CV % Geometric Mean 20.2 + Median 1.570e+01 + Min - Max 8.311e+00 - 2.378e+01 + RENALCLD (L/hr/mg) + n 132 + Mean (SD) 5.093e-03 (1.032e-03) + CV (%) 20.3 + Geometric Mean 4.985e-03 + CV % Geometric Mean 21.4 + Median 5.017e-03 + Min - Max 2.356e-03 - 7.939e-03 + diff --git a/tests/testthat/_snaps/table_pkpt05.md b/tests/testthat/_snaps/table_pkpt05.md new file mode 100644 index 0000000000..d2cef8c1f5 --- /dev/null +++ b/tests/testthat/_snaps/table_pkpt05.md @@ -0,0 +1,55 @@ +# PKPT05 Drug X is produced correctly + + Code + res + Output + Summary of Urine PK Parameter by Treatment Arm, PK Population + Analyte: Plasma Drug X + Visit: CYCLE 1 DAY 1 + + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Arm + PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ARM A + Ae (mg) + 268 1.55 0.338 21.8 1.51 23.0 1.55 0.702 2.46 + CLR (L/hr) + 134 0.0492 0.00961 19.5 0.0482 21.0 0.0491 0.0249 0.0751 + Fe (%) + 268 15.7 3.35 21.3 15.3 22.2 15.8 8.15 24.5 + RENALCLD (L/hr/mg) + 134 0.00487 0.000965 19.8 0.00477 21.2 0.00497 0.00238 0.00726 + ARM C + Ae (mg) + 264 1.54 0.298 19.4 1.51 20.3 1.55 0.85 2.21 + CLR (L/hr) + 132 0.0502 0.0105 20.9 0.0491 21.9 0.0498 0.0251 0.0856 + Fe (%) + 264 16.1 3.1 19.3 15.8 20.2 16 8.5 24.4 + RENALCLD (L/hr/mg) + 132 0.00511 0.000934 18.3 0.00502 19.7 0.00515 0.00236 0.00741 + +# PKPT05 Drug Y is produced correctly + + Code + res + Output + Summary of Urine PK Parameter by Treatment Arm, PK Population + Analyte: Plasma Drug Y + Visit: CYCLE 1 DAY 1 + + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Arm + PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ARM C + Ae (mg) + 264 1.6 0.315 19.7 1.56 21.4 1.6 0.857 2.26 + CLR (L/hr) + 132 0.0497 0.0101 20.3 0.0486 22.0 0.0491 0.0184 0.0776 + Fe (%) + 264 15.8 3.08 19.4 15.5 20.2 15.7 8.31 23.8 + RENALCLD (L/hr/mg) + 132 0.00509 0.00103 20.3 0.00499 21.4 0.00502 0.00236 0.00794 + diff --git a/tests/testthat/_snaps/table_pkpt06.md b/tests/testthat/_snaps/table_pkpt06.md new file mode 100644 index 0000000000..29b2ded6a3 --- /dev/null +++ b/tests/testthat/_snaps/table_pkpt06.md @@ -0,0 +1,32 @@ +# PKPT06 is produced correctly for Drug X + + Code + res + Output + PK Parameter ARM A ARM C + ————————————————————————————————————————————————————————————————————— + RENALCLD (L/hr/mg) + n 134 132 + Mean (SD) 4.873e-03 (9.654e-04) 5.110e-03 (9.339e-04) + CV (%) 19.8 18.3 + Geometric Mean 4.772e-03 5.019e-03 + CV % Geometric Mean 21.2 19.7 + Median 4.967e-03 5.151e-03 + Min - Max 2.385e-03 - 7.258e-03 2.356e-03 - 7.407e-03 + +# PKPT06 is produced correctly for Drug Y + + Code + res + Output + PK Parameter ARM C + ————————————————————————————————————————————— + RENALCLD (L/hr/mg) + n 132 + Mean (SD) 5.093e-03 (1.032e-03) + CV (%) 20.3 + Geometric Mean 4.985e-03 + CV % Geometric Mean 21.4 + Median 5.017e-03 + Min - Max 2.356e-03 - 7.939e-03 + diff --git a/tests/testthat/_snaps/table_pkpt07.md b/tests/testthat/_snaps/table_pkpt07.md new file mode 100644 index 0000000000..32d3a00dde --- /dev/null +++ b/tests/testthat/_snaps/table_pkpt07.md @@ -0,0 +1,37 @@ +# PKPT07 Drug X is produced correctly + + Code + res + Output + Summary of Urine PK Parameter by Treatment Arm, PK Population + Analyte: Plasma Drug X + Visit: CYCLE 1 DAY 1 + + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Arm + PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ARM A + RENALCLD (L/hr/mg) + 134 0.00487 0.000965 19.8 0.00477 21.2 0.00497 0.00238 0.00726 + ARM C + RENALCLD (L/hr/mg) + 132 0.00511 0.000934 18.3 0.00502 19.7 0.00515 0.00236 0.00741 + +# PKPT07 Drug Y is produced correctly + + Code + res + Output + Summary of Urine PK Parameter by Treatment Arm, PK Population + Analyte: Plasma Drug Y + Visit: CYCLE 1 DAY 1 + + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Treatment Arm + PK Parameter n Mean SD CV (%) Geometric Mean CV % Geometric Mean Median Minimum Maximum + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + ARM C + RENALCLD (L/hr/mg) + 132 0.00509 0.00103 20.3 0.00499 21.4 0.00502 0.00236 0.00794 + diff --git a/tests/testthat/_snaps/table_rspt01.md b/tests/testthat/_snaps/table_rspt01.md new file mode 100644 index 0000000000..95b7929c65 --- /dev/null +++ b/tests/testthat/_snaps/table_rspt01.md @@ -0,0 +1,155 @@ +# RSPT01: 1. Best Overall Response + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Responders 100 (74.6%) 84 (62.7%) 81 (61.4%) + 95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) + Unstratified Analysis + Difference in Response rate (%) -11.9 -13.3 + 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) + p-value (Chi-Squared Test with Schouten Correction) 0.0416 0.0245 + Odds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91) + Complete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) + 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) + Partial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) + 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) + Stable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) + 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) + Progressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) + 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) + Not Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) + 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) + +# RSPT01: 2. Best Overall Response (selecting sections to display) + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————————— + Responders 100 (74.6%) 84 (62.7%) 81 (61.4%) + 95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) + Unstratified Analysis + Difference in Response rate (%) -11.9 -13.3 + 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) + p-value (Chi-Squared Test with Schouten Correction) 0.0416 0.0245 + Complete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) + 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) + Partial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) + 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) + Stable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) + 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) + Progressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) + 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) + Not Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) + 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) + +# RSPT01: 3. Best Overall Response (modifying settings) + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————— + Responders 100 (74.6%) 84 (62.7%) 81 (61.4%) + 90% CI (Clopper-Pearson) (67.7, 80.7) (55.3, 69.7) (53.9, 68.5) + Unstratified Analysis + Difference in Response rate (%) -11.9 -13.3 + 90% CI (Anderson-Hauck) (-21.6, -2.3) (-23.0, -3.5) + p-value (Fisher's Exact Test) 0.0479 0.0253 + Odds Ratio (90% CI) 0.57 (0.37 - 0.89) 0.54 (0.35 - 0.84) + Complete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) + 90% CI (Clopper-Pearson) (37.48, 52.25) (28.22, 42.43) (35.88, 50.71) + Partial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) + 90% CI (Clopper-Pearson) (23.36, 37.02) (21.31, 34.67) (12.87, 24.61) + Stable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) + 90% CI (Clopper-Pearson) (3.55, 11.43) (11.38, 22.61) (5.92, 15.20) + Progressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) + 90% CI (Clopper-Pearson) (12.67, 24.25) (7.63, 17.57) (18.90, 31.97) + Not Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) + +# RSPT01: 4. Best Overall Response (with stratified analysis) + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Responders 100 (74.6%) 84 (62.7%) 81 (61.4%) + 95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) + Unstratified Analysis + Difference in Response rate (%) -11.9 -13.3 + 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) + p-value (Chi-Squared Test with Schouten Correction) 0.0416 0.0245 + Odds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91) + Stratified Analysis + Difference in Response rate (%) -11.9 -13.5 + 95% CI (CMH, without correction) (-22.7, -1.0) (-24.5, -2.5) + p-value (Cochran-Mantel-Haenszel Test) 0.0366 0.0180 + Odds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.90) + Complete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) + 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) + Partial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) + 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) + Stable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) + 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) + Progressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) + 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) + Not Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) + 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) + +# RSPT01: 5. Best Overall Response (modifying the definition of overall response) + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Responders 60 (44.8%) 47 (35.1%) 57 (43.2%) + 95% CI (Wald, with correction) (36.0, 53.6) (26.6, 43.5) (34.4, 52.0) + Unstratified Analysis + Difference in Response rate (%) -9.7 -1.6 + 95% CI (Wald, with correction) (-22.1, 2.7) (-14.3, 11.1) + p-value (Chi-Squared Test with Schouten Correction) 0.1197 0.8413 + Odds Ratio (95% CI) 0.67 (0.41 - 1.09) 0.94 (0.58 - 1.52) + Complete Response (CR) 60 (44.8%) 47 (35.1%) 57 (43.2%) + 95% CI (Wald, with correction) (35.98, 53.57) (26.62, 43.53) (34.35, 52.01) + Partial Response (PR) 40 (29.9%) 37 (27.6%) 24 (18.2%) + 95% CI (Wald, with correction) (21.73, 37.97) (19.67, 35.55) (11.22, 25.14) + Stable Disease (SD) 9 (6.7%) 22 (16.4%) 13 (9.8%) + 95% CI (Wald, with correction) (2.11, 11.33) (9.77, 23.06) (4.39, 15.31) + Progressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) + 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) + Not Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) + 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) + +# RSPT01: 6. Best Overall Response (define new sections to display) + + Code + res + Output + ARM A ARM B ARM C + (N=134) (N=134) (N=132) + ———————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Responders 100 (74.6%) 84 (62.7%) 81 (61.4%) + 95% CI (Wald, with correction) (66.9, 82.4) (54.1, 71.2) (52.7, 70.0) + Unstratified Analysis + Difference in Response rate (%) -11.9 -13.3 + 95% CI (Wald, with correction) (-23.7, -0.2) (-25.1, -1.4) + p-value (Chi-Squared Test with Schouten Correction) 0.0416 0.0245 + Odds Ratio (95% CI) 0.57 (0.34 - 0.96) 0.54 (0.32 - 0.91) + No Progression 109 (81.3%) 106 (79.1%) 94 (71.2%) + 95% CI (Wald, with correction) (74.37, 88.31) (71.85, 86.36) (63.11, 79.31) + Progressive Disease (PD) 24 (17.9%) 16 (11.9%) 33 (25.0%) + 95% CI (Wald, with correction) (11.05, 24.78) (6.08, 17.80) (17.23, 32.77) + Not Evaluable (NE) 1 (0.7%) 12 (9.0%) 5 (3.8%) + 95% CI (Wald, with correction) (0.00, 2.58) (3.75, 14.16) (0.15, 7.42) + diff --git a/tests/testthat/_snaps/table_ttet01.md b/tests/testthat/_snaps/table_ttet01.md new file mode 100644 index 0000000000..b64d79d324 --- /dev/null +++ b/tests/testthat/_snaps/table_ttet01.md @@ -0,0 +1,188 @@ +# TTET01 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————— + Patients with event (%) 79 (59%) 87 (64.9%) 116 (87.9%) + Earliest contributing event + Death 79 87 116 + Patients without event (%) 55 (41%) 47 (35.1%) 16 (12.1%) + Time to Event (Months) + Median 41.4 27.5 11.1 + 95% CI (27.7, 54.7) (17.3, 30.2) (9.6, 15.9) + 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2 + Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4 + Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6 + Unstratified Analysis + p-value (log-rank) 0.0334 <0.0001 + Hazard Ratio 1.39 2.75 + 95% CI (1.03, 1.90) (2.05, 3.70) + 6 Months + Patients remaining at risk 106 112 92 + Event Free Rate (%) 83.83 89.16 73.40 + 95% CI (77.49, 90.17) (83.80, 94.53) (65.72, 81.07) + Difference in Event Free Rate 5.33 -10.43 + 95% CI (-2.97, 13.64) (-20.38, -0.48) + p-value (Z-test) 0.2080 0.0399 + 12 Months + Patients remaining at risk 92 83 56 + Event Free Rate (%) 78.03 70.32 46.39 + 95% CI (70.82, 85.24) (62.27, 78.37) (37.59, 55.18) + Difference in Event Free Rate -7.71 -31.64 + 95% CI (-18.51, 3.10) (-43.01, -20.26) + p-value (Z-test) 0.1622 <0.0001 + +# TTET01 variant 2: selecting sections to display + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ——————————————————————————————————————————————————————————————————————————————— + Patients with event (%) 79 (59%) 87 (64.9%) 116 (87.9%) + Patients without event (%) 55 (41%) 47 (35.1%) 16 (12.1%) + Time to Event (Months) + Median 41.4 27.5 11.1 + 95% CI (27.7, 54.7) (17.3, 30.2) (9.6, 15.9) + 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2 + Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4 + Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6 + Unstratified Analysis + p-value (log-rank) 0.0334 <0.0001 + Hazard Ratio 1.39 2.75 + 95% CI (1.03, 1.90) (2.05, 3.70) + 12 Months + Patients remaining at risk 92 83 56 + Event Free Rate (%) 78.03 70.32 46.39 + 95% CI (70.82, 85.24) (62.27, 78.37) (37.59, 55.18) + +# TTET01 variant 3: modifying analysis details like conftype, ties, alpha level + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————— + Patients with event (%) 79 (59%) 87 (64.9%) 116 (87.9%) + Earliest contributing event + Death 79 87 116 + Patients without event (%) 55 (41%) 47 (35.1%) 16 (12.1%) + Time to Event (Months) + Median 41.4 27.5 11.1 + 90% CI (27.9, 54.1) (18.8, 29.9) (9.7, 15.1) + 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2 + Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4 + Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6 + Unstratified Analysis + p-value (log-rank) 0.0334 <0.0001 + Hazard Ratio 1.39 2.75 + 95% CI (1.03, 1.90) (2.05, 3.70) + 12 Months + Patients remaining at risk 92 83 56 + Event Free Rate (%) 78.03 70.32 46.39 + 90% CI (71.24, 83.40) (62.97, 76.49) (38.87, 53.56) + Difference in Event Free Rate -7.71 -31.64 + 97.5% CI (-20.07, 4.65) (-44.64, -18.63) + p-value (Z-test) 0.1622 <0.0001 + +# TTET01 variant 4: with stratified analysis + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————— + Patients with event (%) 79 (59%) 87 (64.9%) 116 (87.9%) + Earliest contributing event + Death 79 87 116 + Patients without event (%) 55 (41%) 47 (35.1%) 16 (12.1%) + Time to Event (Months) + Median 41.4 27.5 11.1 + 95% CI (27.7, 54.7) (17.3, 30.2) (9.6, 15.9) + 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2 + Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4 + Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6 + Unstratified Analysis + p-value (log-rank) 0.0334 <0.0001 + Hazard Ratio 1.39 2.75 + 95% CI (1.03, 1.90) (2.05, 3.70) + Stratified Analysis + p-value (log-rank) 0.0478 <0.0001 + Hazard Ratio 1.36 2.73 + 95% CI (1.00, 1.86) (2.02, 3.69) + 12 Months + Patients remaining at risk 92 83 56 + Event Free Rate (%) 78.03 70.32 46.39 + 95% CI (70.82, 85.24) (62.27, 78.37) (37.59, 55.18) + Difference in Event Free Rate -7.71 -31.64 + 95% CI (-18.51, 3.10) (-43.01, -20.26) + p-value (Z-test) 0.1622 <0.0001 + +# TTET01 variant 5: modifying time point + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————————————————————————————————— + Patients with event (%) 79 (59%) 87 (64.9%) 116 (87.9%) + Earliest contributing event + Death 79 87 116 + Patients without event (%) 55 (41%) 47 (35.1%) 16 (12.1%) + Time to Event (Months) + Median 41.4 27.5 11.1 + 95% CI (27.7, 54.7) (17.3, 30.2) (9.6, 15.9) + 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2 + Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4 + Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6 + Unstratified Analysis + p-value (log-rank) 0.0334 <0.0001 + Hazard Ratio 1.39 2.75 + 95% CI (1.03, 1.90) (2.05, 3.70) + 6 Months + Patients remaining at risk 106 112 92 + Event Free Rate (%) 83.83 89.16 73.40 + 95% CI (77.49, 90.17) (83.80, 94.53) (65.72, 81.07) + Difference in Event Free Rate 5.33 -10.43 + 95% CI (-2.97, 13.64) (-20.38, -0.48) + p-value (Z-test) 0.2080 0.0399 + +# TTET01 variant 6: requesting more than one p-value + + Code + res + Output + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————————————— + Patients with event (%) 79 (59%) 87 (64.9%) 116 (87.9%) + Earliest contributing event + Death 79 87 116 + Patients without event (%) 55 (41%) 47 (35.1%) 16 (12.1%) + Time to Event (Months) + Median 41.4 27.5 11.1 + 95% CI (27.7, 54.7) (17.3, 30.2) (9.6, 15.9) + 25% and 75%-ile 15.4, 75.2 9.5, 54.9 5.3, 25.2 + Range (censored) 0.4 to 154.7 0.9 to 91.0 0.3 to 49.4 + Range (event) 0.3 to 116.4 0.0 to 122.4 0.1 to 101.6 + Unstratified Analysis + p-value (log-rank) 0.0334 <0.0001 + p-value (wald) 0.0342 <0.0001 + p-value (likelihood) 0.0341 <0.0001 + Hazard Ratio 1.39 2.75 + 95% CI (1.03, 1.90) (2.05, 3.70) + 12 Months + Patients remaining at risk 92 83 56 + Event Free Rate (%) 78.03 70.32 46.39 + 95% CI (70.82, 85.24) (62.27, 78.37) (37.59, 55.18) + Difference in Event Free Rate -7.71 -31.64 + 95% CI (-18.51, 3.10) (-43.01, -20.26) + p-value (Z-test) 0.1622 <0.0001 + diff --git a/tests/testthat/_snaps/table_vst01.md b/tests/testthat/_snaps/table_vst01.md new file mode 100644 index 0000000000..a7051ddb59 --- /dev/null +++ b/tests/testthat/_snaps/table_vst01.md @@ -0,0 +1,60 @@ +# VST01 default variant is produced correctly + + Code + res + Output + A: Drug X B: Placebo C: Combination + Value at Visit Change from Baseline Value at Visit Change from Baseline Value at Visit Change from Baseline + (N=134) (N=134) (N=134) (N=134) (N=132) (N=132) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + SCREENING + n 134 0 134 0 132 0 + Mean (SD) 50.0 (7.2) NA 50.8 (8.4) NA 50.2 (7.6) NA + Median 49.7 NA 50.1 NA 49.6 NA + Min - Max 31.7 - 71.2 NA 29.3 - 69.2 NA 26.9 - 70.0 NA + BASELINE + n 134 134 134 134 132 132 + Mean (SD) 48.6 (8.0) 0.0 (0.0) 50.4 (7.9) 0.0 (0.0) 51.1 (7.8) 0.0 (0.0) + Median 48.4 0.0 50.2 0.0 50.8 0.0 + Min - Max 27.7 - 64.6 0.0 - 0.0 21.7 - 67.5 0.0 - 0.0 29.7 - 71.4 0.0 - 0.0 + WEEK 1 DAY 8 + n 134 134 134 134 132 132 + Mean (SD) 50.3 (7.5) 1.7 (10.8) 49.7 (7.7) -0.8 (10.9) 48.9 (7.9) -2.3 (10.4) + Median 50.1 0.6 49.7 -1.1 47.7 -2.2 + Min - Max 33.0 - 69.0 -20.4 - 29.9 33.7 - 66.5 -25.8 - 28.4 30.4 - 67.0 -22.1 - 22.4 + WEEK 2 DAY 15 + n 134 134 134 134 132 132 + Mean (SD) 50.8 (7.8) 2.2 (11.8) 49.7 (8.4) -0.7 (12.4) 50.0 (8.3) -1.1 (11.6) + Median 51.4 3.1 50.2 -0.7 51.0 -2.3 + Min - Max 31.9 - 70.3 -23.9 - 39.2 30.6 - 68.1 -28.4 - 37.0 24.8 - 65.6 -29.2 - 30.7 + WEEK 3 DAY 22 + n 134 134 134 134 132 132 + Mean (SD) 50.7 (7.8) 2.1 (10.9) 49.1 (7.9) -1.3 (11.1) 49.9 (7.7) -1.2 (10.9) + Median 50.2 2.6 49.5 -2.3 50.0 -0.6 + Min - Max 29.1 - 74.9 -25.8 - 30.7 24.5 - 67.1 -28.1 - 33.9 31.5 - 68.5 -29.7 - 27.0 + WEEK 4 DAY 29 + n 134 134 134 134 132 132 + Mean (SD) 50.1 (8.1) 1.5 (10.9) 49.6 (7.1) -0.8 (10.6) 49.7 (8.0) -1.4 (11.0) + Median 49.3 1.2 49.2 -0.8 49.8 -0.2 + Min - Max 29.4 - 71.4 -30.9 - 24.8 32.7 - 67.0 -33.2 - 35.9 28.7 - 68.4 -35.5 - 28.4 + WEEK 5 DAY 36 + n 134 134 134 134 132 132 + Mean (SD) 50.6 (7.5) 2.0 (11.2) 48.4 (8.0) -2.1 (11.7) 49.1 (7.6) -2.0 (10.7) + Median 49.4 1.6 47.7 -2.9 49.2 -2.2 + Min - Max 35.1 - 72.2 -25.2 - 31.5 30.4 - 70.6 -31.2 - 29.2 30.6 - 72.9 -30.5 - 34.6 + Post-Baseline Last + n 134 134 134 134 132 132 + Mean (SD) 50.6 (7.5) 2.0 (11.2) 48.4 (8.0) -2.1 (11.7) 49.1 (7.6) -2.0 (10.7) + Median 49.4 1.6 47.7 -2.9 49.2 -2.2 + Min - Max 35.1 - 72.2 -25.2 - 31.5 30.4 - 70.6 -31.2 - 29.2 30.6 - 72.9 -30.5 - 34.6 + Post-Baseline Minimum + n 134 134 134 134 132 132 + Mean (SD) 41.6 (4.8) -7.0 (9.6) 40.3 (5.3) -10.1 (10.2) 40.5 (5.3) -10.6 (9.1) + Median 42.1 -5.6 40.3 -10.7 40.5 -10.9 + Min - Max 29.1 - 54.2 -30.9 - 13.2 24.5 - 55.4 -33.2 - 27.7 24.8 - 54.9 -35.5 - 13.7 + Post-Baseline Maximum + n 134 134 134 134 132 132 + Mean (SD) 60.0 (4.9) 11.4 (9.3) 58.5 (4.8) 8.1 (9.5) 58.6 (4.8) 7.5 (9.1) + Median 59.7 11.7 58.3 7.5 59.0 6.8 + Min - Max 47.6 - 74.9 -8.6 - 39.2 47.8 - 70.6 -14.0 - 37.0 41.8 - 72.9 -17.3 - 34.6 + diff --git a/tests/testthat/_snaps/table_vst02.md b/tests/testthat/_snaps/table_vst02.md new file mode 100644 index 0000000000..907631ef26 --- /dev/null +++ b/tests/testthat/_snaps/table_vst02.md @@ -0,0 +1,56 @@ +# 1. Vital Sign Abnormalities (Regardless of Abnormality at Baseline, VST02_1) + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + —————————————————————————————————————————————————————————————————————————————————————————————————————— + Parameter / Abnormality Direction + Diastolic Blood Pressure + Low 53/134 (39.6%) 57/134 (42.5%) 54/132 (40.9%) 164/400 (41%) + High 53/134 (39.6%) 51/134 (38.1%) 52/132 (39.4%) 156/400 (39%) + Pulse Rate + Low 63/134 (47%) 53/134 (39.6%) 50/132 (37.9%) 166/400 (41.5%) + High 52/134 (38.8%) 57/134 (42.5%) 39/132 (29.5%) 148/400 (37%) + Respiratory Rate + Low 59/134 (44%) 49/134 (36.6%) 45/132 (34.1%) 153/400 (38.2%) + High 62/134 (46.3%) 54/134 (40.3%) 62/132 (47%) 178/400 (44.5%) + Systolic Blood Pressure + Low 54/134 (40.3%) 55/134 (41%) 57/132 (43.2%) 166/400 (41.5%) + High 58/134 (43.3%) 49/134 (36.6%) 52/132 (39.4%) 159/400 (39.8%) + Temperature + Low 59/134 (44%) 50/134 (37.3%) 61/132 (46.2%) 170/400 (42.5%) + High 45/134 (33.6%) 54/134 (40.3%) 52/132 (39.4%) 151/400 (37.8%) + Weight + Low 62/134 (46.3%) 57/134 (42.5%) 63/132 (47.7%) 182/400 (45.5%) + High 54/134 (40.3%) 58/134 (43.3%) 55/132 (41.7%) 167/400 (41.8%) + +# 2. Vital Sign Abnormalities (Among Subject Without Abnormality at Baseline, VST02_2) + + Code + res + Output + A: Drug X B: Placebo C: Combination All Patients + (N=134) (N=134) (N=132) (N=400) + —————————————————————————————————————————————————————————————————————————————————————————————————————— + Parameter / Abnormality Direction + Diastolic Blood Pressure + Low 45/120 (37.5%) 53/121 (43.8%) 48/118 (40.7%) 146/359 (40.7%) + High 47/113 (41.6%) 48/123 (39%) 48/119 (40.3%) 143/355 (40.3%) + Pulse Rate + Low 60/125 (48%) 49/121 (40.5%) 47/118 (39.8%) 156/364 (42.9%) + High 47/119 (39.5%) 52/119 (43.7%) 34/117 (29.1%) 133/355 (37.5%) + Respiratory Rate + Low 53/123 (43.1%) 45/118 (38.1%) 39/118 (33.1%) 137/359 (38.2%) + High 57/124 (46%) 52/127 (40.9%) 53/118 (44.9%) 162/369 (43.9%) + Systolic Blood Pressure + Low 47/116 (40.5%) 51/120 (42.5%) 51/120 (42.5%) 149/356 (41.9%) + High 55/121 (45.5%) 43/125 (34.4%) 49/124 (39.5%) 147/370 (39.7%) + Temperature + Low 47/119 (39.5%) 44/119 (37%) 55/115 (47.8%) 146/353 (41.4%) + High 43/128 (33.6%) 47/121 (38.8%) 50/122 (41%) 140/371 (37.7%) + Weight + Low 54/120 (45%) 50/117 (42.7%) 57/119 (47.9%) 161/356 (45.2%) + High 49/123 (39.8%) 54/121 (44.6%) 47/113 (41.6%) 150/357 (42%) + diff --git a/tests/testthat/test-abnormal_by_baseline.R b/tests/testthat/test-abnormal_by_baseline.R index 33b7a4c411..d5f8bbd90f 100644 --- a/tests/testthat/test-abnormal_by_baseline.R +++ b/tests/testthat/test-abnormal_by_baseline.R @@ -84,14 +84,15 @@ testthat::test_that("count_abnormal_by_baseline throws warning with character va ) # Check with LOW abnormality. - result <- testthat::expect_warning( - s_count_abnormal_by_baseline( + testthat::expect_warning( + result <- s_count_abnormal_by_baseline( df = df, .var = "myrange", abnormal = "LOW", variables = list(id = "myid", baseline = "mybase") ) ) + expected <- list(fraction = list( "not_abnormal" = formatters::with_label(c(num = 2L, denom = 4L), "Not low baseline status"), "abnormal" = formatters::with_label(c(num = 0L, denom = 1L), "Low baseline status"), diff --git a/tests/testthat/test-combination_function.R b/tests/testthat/test-combination_function.R index ecce547d14..7ffc4da2b4 100644 --- a/tests/testthat/test-combination_function.R +++ b/tests/testthat/test-combination_function.R @@ -3,7 +3,7 @@ testthat::test_that("CombinationFunction class can be used with standard constru x == 5 } comb_fun <- methods::new("CombinationFunction", fun) - testthat::expect_is(comb_fun, "CombinationFunction") + testthat::expect_s4_class(comb_fun, "CombinationFunction") testthat::expect_identical(fun(5), comb_fun(5)) testthat::expect_identical(fun(3), comb_fun(3)) }) @@ -25,7 +25,7 @@ testthat::test_that("CombinationFunction `&` method works", { test < 10 }) c <- a & b - testthat::expect_is(c, "CombinationFunction") + testthat::expect_s4_class(c, "CombinationFunction") testthat::expect_identical(a(5) & b(5), c(5)) testthat::expect_identical(a(1) & b(1), c(1)) }) @@ -38,7 +38,7 @@ testthat::test_that("CombinationFunction `|` method works", { test < 10 }) c <- a | b - testthat::expect_is(c, "CombinationFunction") + testthat::expect_s4_class(c, "CombinationFunction") testthat::expect_identical(a(1) | b(1), c(1)) testthat::expect_identical(a(11) | b(11), c(11)) }) @@ -48,7 +48,7 @@ testthat::test_that("CombinationFunction `!` method works", { test > 3 }) b <- !a - testthat::expect_is(b, "CombinationFunction") + testthat::expect_s4_class(b, "CombinationFunction") testthat::expect_identical(!a(1), b(1)) testthat::expect_identical(!a(10), b(10)) }) @@ -64,7 +64,7 @@ testthat::test_that("CombinationFunction chain of logical combinations works", { test %% 2 == 0 }) d <- a & (b | c) - testthat::expect_is(d, "CombinationFunction") + testthat::expect_s4_class(d, "CombinationFunction") testthat::expect_identical(a(5) & (b(5) | c(5)), d(5)) testthat::expect_identical(a(12) & (b(12) | c(12)), d(12)) }) diff --git a/tests/testthat/test-compare_variables.R b/tests/testthat/test-compare_variables.R index 910bcb5adf..72b186023e 100644 --- a/tests/testthat/test-compare_variables.R +++ b/tests/testthat/test-compare_variables.R @@ -25,7 +25,7 @@ testthat::test_that("s_compare for factor works in usual case", { y <- factor(c("a", "b", "c")) result <- testthat::expect_silent(s_compare(x = x, .ref_group = y, .in_ref_col = FALSE)) testthat::expect_named(result, c("n", "count", "count_fraction", "n_blq", "pval")) - testthat::expect_equal(result$pval, 0.7659, tol = 1e-4) + testthat::expect_equal(result$pval, 0.7659, tolerance = 1e-4) }) testthat::test_that("s_compare for factor handles explicit NAs as expected", { @@ -38,7 +38,7 @@ testthat::test_that("s_compare for factor handles explicit NAs as expected", { .in_ref_col = FALSE, na.rm = TRUE )) - testthat::expect_equal(result_without_na$pval, 0.7659, tol = 1e-4) + testthat::expect_equal(result_without_na$pval, 0.7659, tolerance = 1e-4) result_with_na <- testthat::expect_silent(s_compare( x = x, @@ -46,16 +46,16 @@ testthat::test_that("s_compare for factor handles explicit NAs as expected", { .in_ref_col = FALSE, na.rm = FALSE )) - testthat::expect_equal(result_with_na$pval, 0.9063, tol = 1e-4) + testthat::expect_equal(result_with_na$pval, 0.9063, tolerance = 1e-4) }) testthat::test_that("s_compare for character works as expected", { x <- c("a", "a", "b", "c", "a") y <- c("a", "b", "c") - result <- testthat::expect_warning( - s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = "x"), + suppressWarnings(testthat::expect_warning( + result <- s_compare(x, .ref_group = y, .in_ref_col = FALSE, .var = "x"), "automatically converting character variable x to factor" - ) + )) expected <- list( n = 5L, count = list(a = 3L, b = 1L, c = 1L), @@ -63,14 +63,14 @@ testthat::test_that("s_compare for character works as expected", { n_blq = 0L, pval = 0.7659 ) - testthat::expect_equal(result, expected, tol = 1e-4) + testthat::expect_equal(result, expected, tolerance = 1e-4) }) testthat::test_that("s_compare for logical works as expected", { x <- c(TRUE, FALSE, TRUE, TRUE) y <- c(FALSE, FALSE, TRUE) result <- testthat::expect_silent(s_compare(x, .ref_group = y, .in_ref_col = FALSE)) - testthat::expect_equal(result$pval, 0.2702, tol = 1e-4) + testthat::expect_equal(result$pval, 0.2702, tolerance = 1e-3) }) testthat::test_that("s_compare for logical handles NAs as FALSE if not removed", { @@ -82,7 +82,7 @@ testthat::test_that("s_compare for logical handles NAs as FALSE if not removed", .ref_group = replace(y, is.na(y), FALSE), .in_ref_col = FALSE ) - testthat::expect_identical(result, expected) + testthat::expect_identical(result, expected, tolerance = 1e-4) }) testthat::test_that("compare_vars works with default settings in rtables layout pipeline", { diff --git a/tests/testthat/test-count_patients_with_event.R b/tests/testthat/test-count_patients_with_event.R index f7c339d7ae..afd1b42080 100644 --- a/tests/testthat/test-count_patients_with_event.R +++ b/tests/testthat/test-count_patients_with_event.R @@ -338,6 +338,6 @@ testthat::test_that("s_count_patients_with_event works with factor filters", { .var = "SUBJID", filters = c("AEOUT" = "FATAL") ) - expected <- list(n = 3, count = 1, count_fraction = c(1.0000000, 0.3333333), n_blq = 0L) + expected <- list(n = 3, count = 1, count_fraction = c(1.0000000, 0.33333333), n_blq = 0L) testthat::expect_equal(result, expected, tolerance = 1e-7) }) diff --git a/tests/testthat/test-coxph.R b/tests/testthat/test-coxph.R index 5d405e9343..c1155d7996 100644 --- a/tests/testthat/test-coxph.R +++ b/tests/testthat/test-coxph.R @@ -1,5 +1,5 @@ testthat::test_that("pairwise works correctly", { - result <- testthat::expect_warning(lm(SEX ~ pairwise(ARM), data = adsl_raw)) + suppressWarnings(testthat::expect_warning(result <- lm(SEX ~ pairwise(ARM), data = adsl_raw))) expected <- c( "(Intercept)" = 1.41045, "pairwise(ARM)B: Placebo" = -0.02239, "pairwise(ARM)C: Combination" = 0.05925 diff --git a/tests/testthat/test-coxreg.R b/tests/testthat/test-coxreg.R index 49ef7796a4..faaf588dd1 100644 --- a/tests/testthat/test-coxreg.R +++ b/tests/testthat/test-coxreg.R @@ -270,7 +270,7 @@ testthat::test_that("fit_coxreg_univar returns model results as expected", { vars = variables, at = list() ) - testthat::expect_equal(result$mod, expected$mod) + testthat::expect_equal(result$mod, expected$mod, ignore_attr = TRUE) }) testthat::test_that("fit_coxreg_univar runs with non-represented level of a factor", { @@ -529,7 +529,7 @@ testthat::test_that("h_coxreg_inter_effect.numerics works with _:_ in effect lev ) ) # The first column in the effect (arm/armcd) and expected to vary. - testthat::expect_equal(result[, -1], expected[, -1], check.attributes = FALSE) + testthat::expect_equal(result[, -1], expected[, -1], ignore_attr = TRUE) }) # h_coxreg_inter_estimations ---- @@ -587,7 +587,7 @@ testthat::test_that("fit_coxreg_multivar returns model results as expected", { control = control, vars = variables ) - testthat::expect_equal(result$mod, expected$mod) + testthat::expect_equal(result$mod, expected$mod, ignore_attr = TRUE) }) testthat::test_that("fit_coxreg_multivar is stopped when likelihood method is used together with strata", { @@ -604,7 +604,6 @@ testthat::test_that("fit_coxreg_multivar is stopped when likelihood method is us ) }) - testthat::test_that("fit_coxreg_multivar works correctly also without treatment arm", { data <- dta_bladder_raw control <- control_coxreg(conf_level = 0.9) @@ -617,8 +616,10 @@ testthat::test_that("fit_coxreg_multivar works correctly also without treatment data = data, control = control )) - testthat::expect_is(result$mod, "coxph") - testthat::expect_equal(stats::formula(result$mod), survival::Surv(time, status) ~ 1 + covar1 + covar2) + testthat::expect_s3_class(result$mod, "coxph") + testthat::expect_equal(stats::formula(result$mod), survival::Surv(time, status) ~ 1 + covar1 + covar2, + ignore_attr = TRUE + ) }) # tidy.coxreg.multivar ---- diff --git a/tests/testthat/test-decorate_grob.R b/tests/testthat/test-decorate_grob.R index 1715d35f2b..60323a9393 100644 --- a/tests/testthat/test-decorate_grob.R +++ b/tests/testthat/test-decorate_grob.R @@ -44,9 +44,9 @@ testthat::test_that("decorate_grob returns no warnings when creating a non-empty testthat::test_that("split_string works with default settings", { result <- split_string( "The species are Iris setosa, versicolor, and virginica.", - width = grid::unit(3, "cm") + width = grid::unit(4, "cm") ) - expected <- "The species\nare Iris setosa,\nversicolor, and\nvirginica." + expected <- "The species are Iris\nsetosa, versicolor,\nand virginica." testthat::expect_identical(result, expected) }) diff --git a/tests/testthat/test-estimate_incidence_rate.R b/tests/testthat/test-estimate_incidence_rate.R index ce98715999..b95c0da8a0 100644 --- a/tests/testthat/test-estimate_incidence_rate.R +++ b/tests/testthat/test-estimate_incidence_rate.R @@ -98,7 +98,7 @@ testthat::test_that("s_incidence_rate works as expected with healthy input", { rate_ci = formatters::with_label(c(19.40154, 100.50487), "90% CI") ) - testthat::expect_equal(result, expected, tolerance = 1e-4, check.attributes = TRUE) + testthat::expect_equal(result, expected, tolerance = 1e-4) }) testthat::test_that("estimate_incidence_rate works as expected with healthy input", { diff --git a/tests/testthat/test-estimate_proportion.R b/tests/testthat/test-estimate_proportion.R index 2d424fb56f..80c8ea3f70 100644 --- a/tests/testthat/test-estimate_proportion.R +++ b/tests/testthat/test-estimate_proportion.R @@ -26,7 +26,7 @@ testthat::test_that("strata_normal_quantile works with general factor table", { result <- strata_normal_quantile(vars, weights, 0.95) - testthat::expect_equal(result, 1.133272, tol = 0.000001) + testthat::expect_equal(result, 1.133272, tolerance = 0.000001) }) testthat::test_that("update_weights_strat_wilson works with general inputs", { @@ -43,7 +43,7 @@ testthat::test_that("update_weights_strat_wilson works with general inputs", { "weights" = c(0.2067191, 0.1757727, 0.1896962, 0.1636346, 0.1357615, 0.1284160) ) - testthat::expect_equal(result[1:2], expected, tol = 0.000001) + testthat::expect_equal(result[1:2], expected, tolerance = 0.000001) }) testthat::test_that("update_weights_strat_wilson convergence test", { @@ -211,10 +211,10 @@ testthat::test_that("prop_strat_wilson output matches equivalent SAS function ou testthat::test_that("s_proportion returns right result", { result <- s_proportion(c(1, 0, 1, 0)) expected <- list( - n_prop = c(2, .5), - prop_ci = c(0, 100) + n_prop = formatters::with_label(c(2, .5), "Responders"), + prop_ci = formatters::with_label(c(0, 100), "95% CI (Wald, with correction)") ) - testthat::expect_equal(expected, result, tolerance = 1e-4, check.attributes = FALSE) + testthat::expect_equal(expected, result, tolerance = 1e-4, ignore_attr = FALSE) }) testthat::test_that("`s_proportion` works with Jeffreys CI", { @@ -227,13 +227,13 @@ testthat::test_that("`s_proportion` works with Jeffreys CI", { ) # according to SAS. expected <- list( - n_prop = c(4, 4 / 6), + n_prop = formatters::with_label(c(4, 4 / 6), "Responders"), prop_ci = formatters::with_label( c(34.0802, 89.5730), - label = "90% CI for Response Rates (Jeffreys)" + label = "90% CI (Jeffreys)" ) ) - testthat::expect_equal(result, expected, tol = 0.0001, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 0.0001, ignore_attr = FALSE) # Corner case: Only responders. rsp <- c(TRUE, TRUE, TRUE, TRUE) @@ -244,13 +244,13 @@ testthat::test_that("`s_proportion` works with Jeffreys CI", { ) # according to SAS. expected <- list( - n_prop = c(4, 1), + n_prop = formatters::with_label(c(4, 1), "Responders"), prop_ci = formatters::with_label( c(55.5237, 100), - label = "95% CI for Response Rates (Jeffreys)" + label = "95% CI (Jeffreys)" ) ) - testthat::expect_equal(result, expected, tol = 0.0001, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 0.0001, ignore_attr = FALSE) }) testthat::test_that("`s_proportion` works with Agresti-Coull CI", { @@ -263,13 +263,13 @@ testthat::test_that("`s_proportion` works with Agresti-Coull CI", { ) # according to SAS. expected <- list( - n_prop = c(4, 4 / 6), + n_prop = formatters::with_label(c(4, 4 / 6), "Responders"), prop_ci = formatters::with_label( c(34.3585, 88.6154), - label = "90% CI for Response Rates (Agresti-Coull)" + label = "90% CI (Agresti-Coull)" ) ) - testthat::expect_equal(result, expected, tol = 0.0001, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 0.0001, ignore_attr = FALSE) # Edge case: Only responders. rsp <- c(TRUE, TRUE, TRUE, TRUE) @@ -280,14 +280,14 @@ testthat::test_that("`s_proportion` works with Agresti-Coull CI", { ) # according to SAS. expected <- list( - n_prop = c(4, 1), + n_prop = formatters::with_label(c(4, 1), "Responders"), prop_ci = formatters::with_label( c(45.4050, 100), - label = "95% CI for Response Rates (Agresti-Coull)" + label = "95% CI (Agresti-Coull)" ) ) # Small additional difference acknowledged here. - testthat::expect_equal(result, expected, tol = 0.00011, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 0.00011, ignore_attr = FALSE) }) testthat::test_that("`estimate_proportion` is compatible with `rtables`", { @@ -313,7 +313,7 @@ testthat::test_that("`estimate_proportion` is compatible with `rtables`", { c("(95.8940, 99.8681)", "(89.6097, 97.4468)", "(95.8337, 99.8661)", "(95.7797, 98.8118)") ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) }) testthat::test_that("`estimate_proportion` and strat_wilson is compatible with `rtables`", { diff --git a/tests/testthat/test-fit_rsp_step.R b/tests/testthat/test-fit_rsp_step.R index 049044e085..5544e34f90 100644 --- a/tests/testthat/test-fit_rsp_step.R +++ b/tests/testthat/test-fit_rsp_step.R @@ -23,7 +23,7 @@ testthat::test_that("fit_rsp_step works as expected with default options", { variables = variables, data = data )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 11L) testthat::expect_identical( colnames(result), @@ -55,7 +55,7 @@ testthat::test_that("fit_rsp_step works as expected with global model fit", { ) ) )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 8L) testthat::expect_identical( colnames(result), @@ -80,7 +80,7 @@ testthat::test_that("fit_rsp_step works as expected with strata", { data = data, control = c(control_logistic(), control_step(bandwidth = 0.6)) )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 11L) testthat::expect_identical( colnames(result), @@ -105,7 +105,7 @@ testthat::test_that("fit_rsp_step works as expected with null bandwidth", { data = data, control = c(control_logistic(), control_step(bandwidth = NULL)) )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 11L) testthat::expect_identical( colnames(result), diff --git a/tests/testthat/test-fit_survival_step.R b/tests/testthat/test-fit_survival_step.R index 457efa8032..242e4292d9 100644 --- a/tests/testthat/test-fit_survival_step.R +++ b/tests/testthat/test-fit_survival_step.R @@ -28,7 +28,7 @@ testthat::test_that("fit_survival_step works as expected with default options", variables = variables, data = data )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 12L) testthat::expect_identical( colnames(result), @@ -62,7 +62,7 @@ testthat::test_that("fit_survival_step works as expected with global model fit", ) ) )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 9L) testthat::expect_identical( colnames(result), @@ -87,7 +87,7 @@ testthat::test_that("fit_survival_step works as expected with null bandwidth", { data = data, control = c(control_logistic(), control_step(bandwidth = NULL)) )) - testthat::expect_is(result, c("matrix", "step")) + testthat::expect_s3_class(result, c("matrix", "step")) testthat::expect_identical(ncol(result), 12L) testthat::expect_identical( colnames(result), diff --git a/tests/testthat/test-g_forest.R b/tests/testthat/test-g_forest.R new file mode 100644 index 0000000000..b0de17e777 --- /dev/null +++ b/tests/testthat/test-g_forest.R @@ -0,0 +1,51 @@ +adrs <- adrs_raw +n_records <- 20 +adrs_labels <- formatters::var_labels(adrs, fill = TRUE) +adrs <- adrs %>% + dplyr::filter(PARAMCD == "BESRSPI") %>% + dplyr::filter(ARM %in% c("A: Drug X", "B: Placebo")) %>% + dplyr::slice(seq_len(n_records)) %>% + droplevels() %>% + dplyr::mutate(rsp = AVALC == "CR") + +formatters::var_labels(adrs) <- c(adrs_labels, "Response") +df <- extract_rsp_subgroups( + variables = list(rsp = "rsp", arm = "ARM", subgroups = c("SEX", "STRATA2")), + data = adrs +) + +testthat::test_that("g_forest default plot works", { + tbl <- basic_table() %>% + tabulate_rsp_subgroups(df) + + result <- testthat::expect_no_error( + g_forest( + tbl, + draw = FALSE + ) + ) +}) + +testthat::test_that("g_forest works with custom arguments", { + tbl <- rtable( + header = rheader( + rrow("", rcell("A", colspan = 2)), + rrow("", "c1", "c2") + ), + rrow("row 1", 1, c(.8, 1.2)), + rrow("row 2", 1.2, c(1.1, 1.4)) + ) + + result <- testthat::expect_no_error( + g_forest( + tbl = tbl, + col_x = 1, + col_ci = 2, + xlim = c(0.5, 2), + x_at = c(0.5, 1, 2), + vline = 1, + forest_header = c("Hello", "World"), + draw = FALSE + ) + ) +}) diff --git a/tests/testthat/test-g_step.R b/tests/testthat/test-g_step.R index 72e0e48407..e70c871b7f 100644 --- a/tests/testthat/test-g_step.R +++ b/tests/testthat/test-g_step.R @@ -90,14 +90,14 @@ testthat::test_that("tidy.step gives expected warnings when there are NAs in y v control = control_summarize_vars(conf_level = 0.9), variables = list(biomarker = "bla") ) - testthat::expect_warning( + suppressWarnings(testthat::expect_warning( broom::tidy(step_matrix), "Missing values in the point estimate or CI columns" - ) - testthat::expect_warning( + )) + suppressWarnings(testthat::expect_warning( broom::tidy(step_matrix), "Consider using larger `bandwidth`, less `num_points`" - ) + )) }) testthat::test_that("tidy.step gives expected warnings when there are very large values in y variables", { @@ -107,12 +107,12 @@ testthat::test_that("tidy.step gives expected warnings when there are very large control = control_summarize_vars(conf_level = 0.9), variables = list(biomarker = "bla") ) - testthat::expect_warning( + suppressWarnings(testthat::expect_warning( broom::tidy(step_matrix), "Very large absolute values in the point estimate or CI columns" - ) - testthat::expect_warning( + )) + suppressWarnings(testthat::expect_warning( broom::tidy(step_matrix), "Consider using larger `bandwidth`, less `num_points`" - ) + )) }) diff --git a/tests/testthat/test-h_response_biomarkers_subgroups.R b/tests/testthat/test-h_response_biomarkers_subgroups.R index 38d1cf9c08..2bf58eb44d 100644 --- a/tests/testthat/test-h_response_biomarkers_subgroups.R +++ b/tests/testthat/test-h_response_biomarkers_subgroups.R @@ -64,7 +64,7 @@ testthat::test_that("h_logistic_mult_cont_df works as expected", { pval = c(0.195658638331358, 0.949797749266217), pval_label = c("p-value (Wald)", "p-value (Wald)") ) - testthat::expect_equal(result, expected, tol = 1e-5) + testthat::expect_equal(result, expected, tolerance = 1e-5) }) testthat::test_that("h_logistic_mult_cont_df returns missing values if data is empty (0 rows)", { @@ -121,7 +121,7 @@ testthat::test_that("h_logistic_mult_cont_df also works with response not being pval = c(0.195658638331358, 0.949797749266217), pval_label = c("p-value (Wald)", "p-value (Wald)") ) - testthat::expect_equal(result, expected, tol = 1e-5) + testthat::expect_equal(result, expected, tolerance = 1e-5) }) # h_tab_rsp_one_biomarker ---- diff --git a/tests/testthat/test-h_response_subgroups.R b/tests/testthat/test-h_response_subgroups.R index 42fa4ebc70..95466920e8 100644 --- a/tests/testthat/test-h_response_subgroups.R +++ b/tests/testthat/test-h_response_subgroups.R @@ -97,7 +97,7 @@ testthat::test_that("h_proportion_subgroups_df functions as expected with valid stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_proportion_subgroups_df functions as expected when subgroups is NULL.", { @@ -120,7 +120,7 @@ testthat::test_that("h_proportion_subgroups_df functions as expected when subgro stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_proportion_subgroups_df works as expected with groups_lists", { @@ -160,7 +160,7 @@ testthat::test_that("h_odds_ratio_df functions as expected with valid input and stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_df functions as expected with valid input and non-default arguments", { @@ -185,7 +185,7 @@ testthat::test_that("h_odds_ratio_df functions as expected with valid input and stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_df functions as expected with strata", { @@ -211,7 +211,7 @@ testthat::test_that("h_odds_ratio_df functions as expected with strata", { stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_df functions when 0 obs in one arm", { @@ -236,7 +236,7 @@ testthat::test_that("h_odds_ratio_df functions when 0 obs in one arm", { stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_subgroups_df functions as expected with valid input and default arguments", { @@ -261,7 +261,7 @@ testthat::test_that("h_odds_ratio_subgroups_df functions as expected with valid stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_subgroups_df functions as expected when subgroups is NULL.", { @@ -286,7 +286,7 @@ testthat::test_that("h_odds_ratio_subgroups_df functions as expected when subgro stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_subgroups_df functions as expected with strata", { @@ -319,7 +319,7 @@ testthat::test_that("h_odds_ratio_subgroups_df functions as expected with strata stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_odds_ratio_subgroups_df works as expected with groups_lists", { diff --git a/tests/testthat/test-h_step.R b/tests/testthat/test-h_step.R index 4d01071ec1..91328cc7cd 100644 --- a/tests/testthat/test-h_step.R +++ b/tests/testthat/test-h_step.R @@ -24,14 +24,14 @@ testthat::test_that("h_step_window works as expected for percentiles", { x <- -5:10 control <- control_step(use_percentile = TRUE, num_points = 5L, bandwidth = 0.2) result <- testthat::expect_silent(h_step_window(x = x, control = control)) - testthat::expect_is(result, "list") + testthat::expect_type(result, "list") testthat::expect_named(result, c("sel", "interval")) sel <- result$sel - testthat::expect_is(sel, "matrix") + testthat::expect_true(is.matrix(sel)) testthat::expect_identical(dim(sel), c(length(x), control$num_points)) testthat::expect_identical(mode(sel), "logical") interval <- result$interval - testthat::expect_is(interval, "matrix") + testthat::expect_true(is.matrix(interval)) testthat::expect_identical( colnames(interval), c( @@ -46,12 +46,12 @@ testthat::test_that("h_step_window works as expected for actual biomarker values x <- -5:10 control <- control_step(use_percentile = FALSE, num_points = 5L, bandwidth = 3) result <- testthat::expect_silent(h_step_window(x = x, control = control)) - testthat::expect_is(result, "list") + testthat::expect_type(result, "list") testthat::expect_named(result, c("sel", "interval")) sel <- result$sel testthat::expect_true(all(colSums(sel) %in% (control$bandwidth * 2 + c(0L, 1L)))) interval <- result$interval - testthat::expect_is(interval, "matrix") + testthat::expect_true(is.matrix(interval)) testthat::expect_identical( colnames(interval), c("Interval Center", "Interval Lower", "Interval Upper") @@ -84,7 +84,7 @@ testthat::test_that("h_step_trt_effect works for Cox models without interaction" x = 100 # Note: this does not have any effect on results, because there is no interaction. ) coef_sum <- summary(mod)$coefficients - testthat::expect_equivalent(result, coef_sum["armcdB", c("coef", "se(coef)")]) + testthat::expect_equal(result, coef_sum["armcdB", c("coef", "se(coef)")], ignore_attr = TRUE) }) testthat::test_that("h_step_trt_effect works for Cox models with interaction", { @@ -102,7 +102,7 @@ testthat::test_that("h_step_trt_effect works for Cox models with interaction", { x = 0 ) coef_sum <- summary(mod)$coefficients - testthat::expect_equivalent(result, coef_sum["armcdB", c("coef", "se(coef)")]) + testthat::expect_equal(result, coef_sum["armcdB", c("coef", "se(coef)")], ignore_attr = TRUE) # Then at age = 50. Compare point estimate with manual calculation. result <- h_step_trt_effect( data = dta_simple, @@ -111,9 +111,9 @@ testthat::test_that("h_step_trt_effect works for Cox models with interaction", { x = 50 ) est_manual <- sum(stats::coef(mod)[c("armcdB", "age", "armcdB:age")] * (c(1, 50, 50) - c(0, 50, 0))) - testthat::expect_equivalent(result["est"], est_manual) + testthat::expect_equal(result["est"], est_manual, ignore_attr = TRUE) # Regression test for se. - testthat::expect_equivalent(result["se"], 1.322242, tol = 1e-5) + testthat::expect_equal(result["se"], 1.322242, tolerance = 1e-5, ignore_attr = TRUE) }) testthat::test_that("h_step_trt_effect works for Cox models with strata", { @@ -134,7 +134,7 @@ testthat::test_that("h_step_trt_effect works for Cox models with strata", { x = 0 )) coef_sum <- summary(mod)$coefficients - testthat::expect_equivalent(result, coef_sum["armcdB", c("coef", "se(coef)")]) + testthat::expect_equal(result, coef_sum["armcdB", c("coef", "se(coef)")], ignore_attr = TRUE) }) testthat::test_that("h_step_trt_effect works for logistic regression models without interaction", { @@ -152,7 +152,7 @@ testthat::test_that("h_step_trt_effect works for logistic regression models with x = 100 # Note: this does not have any effect on results, because there is no interaction. ) coef_sum <- summary(mod)$coefficients - testthat::expect_equivalent(result, coef_sum["armcdB", c("Estimate", "Std. Error")]) + testthat::expect_equal(result, coef_sum["armcdB", c("Estimate", "Std. Error")], ignore_attr = TRUE) }) testthat::test_that("h_step_trt_effect works for logistic regression models with interaction", { @@ -170,7 +170,7 @@ testthat::test_that("h_step_trt_effect works for logistic regression models with x = 0 ) coef_sum <- summary(mod)$coefficients - testthat::expect_equivalent(result, coef_sum["ARMBINARM B", c("Estimate", "Std. Error")]) + testthat::expect_equal(result, coef_sum["ARMBINARM B", c("Estimate", "Std. Error")], ignore_attr = TRUE) # Then at age = 50. Compare point estimate with manual calculation. result <- h_step_trt_effect( data = dta, @@ -179,9 +179,9 @@ testthat::test_that("h_step_trt_effect works for logistic regression models with x = 50 ) est_manual <- sum(stats::coef(mod)[c("ARMBINARM B", "AGE", "ARMBINARM B:AGE")] * (c(1, 50, 50) - c(0, 50, 0))) - testthat::expect_equivalent(result["est"], est_manual) + testthat::expect_equal(result["est"], est_manual, ignore_attr = TRUE) # Regression test for se. - testthat::expect_equivalent(result["se"], 0.2153840, tol = 1e-5) + testthat::expect_equal(result["se"], 0.2153840, tolerance = 1e-5, ignore_attr = TRUE) }) testthat::test_that("h_step_trt_effect works for conditional logistic regression without interaction", { @@ -199,7 +199,7 @@ testthat::test_that("h_step_trt_effect works for conditional logistic regression x = 0 ) coef_sum <- summary(mod)$coefficients - testthat::expect_equivalent(result, coef_sum["ARMBINARM B", c("coef", "se(coef)")]) + testthat::expect_equal(result, coef_sum["ARMBINARM B", c("coef", "se(coef)")], ignore_attr = TRUE) }) testthat::test_that("h_step_trt_effect works for conditional logistic regression with interaction", { @@ -217,9 +217,9 @@ testthat::test_that("h_step_trt_effect works for conditional logistic regression x = 50 ) est_manual <- sum(stats::coef(mod)[c("ARMBINARM B", "AGE", "ARMBINARM B:AGE")] * (c(1, 50, 50) - c(0, 50, 0))) - testthat::expect_equivalent(result["est"], est_manual) + testthat::expect_equal(result["est"], est_manual, ignore_attr = TRUE) # Regression test for se. - testthat::expect_equivalent(result["se"], 0.2100507, tol = 1e-5) + testthat::expect_equal(result["se"], 0.2100507, tolerance = 1e-5, ignore_attr = TRUE) }) # h_step_survival_formula ---- @@ -230,14 +230,16 @@ testthat::test_that("h_step_survival_formula works correctly without covariates list(arm = "TRT", biomarker = "BM", event = "EV", time = "TIME"), control = control_step(degree = 3) ), - Surv(TIME, EV) ~ TRT * stats::poly(BM, degree = 3, raw = TRUE) + Surv(TIME, EV) ~ TRT * stats::poly(BM, degree = 3, raw = TRUE), + ignore_attr = TRUE ) testthat::expect_equal( h_step_survival_formula( list(arm = "TRT", biomarker = "BM", event = "EV", time = "TIME"), control = control_step(degree = 0) ), - Surv(TIME, EV) ~ TRT + Surv(TIME, EV) ~ TRT, + ignore_attr = TRUE ) }) @@ -247,7 +249,8 @@ testthat::test_that("h_step_survival_formula works correctly with covariates", { list(arm = "TRT", biomarker = "BM", event = "EV", time = "TIME", covariates = c("A", "B")), control = control_step(degree = 2) ), - Surv(TIME, EV) ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + A + B + Surv(TIME, EV) ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + A + B, + ignore_attr = TRUE ) }) @@ -256,7 +259,8 @@ testthat::test_that("h_step_survival_formula works correctly with strata", { h_step_survival_formula( list(arm = "TRT", biomarker = "BM", event = "EV", time = "TIME", strata = c("A", "B")), ), - Surv(TIME, EV) ~ TRT + strata(A, B) + Surv(TIME, EV) ~ TRT + strata(A, B), + ignore_attr = TRUE ) }) @@ -282,10 +286,10 @@ testthat::test_that("h_step_survival_est works as expected", { variables = vars, x = age_vals )) - testthat::expect_is(result, "matrix") + testthat::expect_true(is.matrix(result)) testthat::expect_identical(dim(result), c(3L, 6L)) testthat::expect_identical(colnames(result), c("n", "events", "loghr", "se", "ci_lower", "ci_upper")) - testthat::expect_equal(result[, "loghr"], c(1.075486, 1.082507, 1.089528), tol = 1e-6) + testthat::expect_equal(result[, "loghr"], c(1.075486, 1.082507, 1.089528), tolerance = 1e-6) }) testthat::test_that("h_step_survival_est gives a readable warning when fitting warnings occur", { @@ -322,13 +326,15 @@ testthat::test_that("h_step_rsp_formula works correctly without covariates", { list(arm = "TRT", biomarker = "BM", response = "RSP"), control = c(control_step(degree = 3), control_logistic()) ), - RSP ~ TRT * stats::poly(BM, degree = 3, raw = TRUE) + RSP ~ TRT * stats::poly(BM, degree = 3, raw = TRUE), + ignore_attr = TRUE ) testthat::expect_equal( h_step_rsp_formula( list(arm = "TRT", biomarker = "BM", response = "RSP") ), - RSP ~ TRT + RSP ~ TRT, + ignore_attr = TRUE ) }) @@ -338,7 +344,8 @@ testthat::test_that("h_step_rsp_formula works correctly with covariates", { list(arm = "TRT", biomarker = "BM", response = "RSP", covariates = c("A", "B")), control = c(control_logistic(), control_step(degree = 2)) ), - RSP ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + A + B + RSP ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + A + B, + ignore_attr = TRUE ) }) @@ -351,7 +358,8 @@ testthat::test_that("h_step_rsp_formula works correctly with different response control_step(degree = 1) ) ), - I(AVAL == "CR") ~ TRT * stats::poly(BM, degree = 1, raw = TRUE) + I(AVAL == "CR") ~ TRT * stats::poly(BM, degree = 1, raw = TRUE), + ignore_attr = TRUE ) }) @@ -361,14 +369,16 @@ testthat::test_that("h_step_rsp_formula works correctly with strata", { list(arm = "TRT", biomarker = "BM", response = "RSP", strata = c("A", "B")), control = c(control_logistic(), control_step(degree = 2)) ), - RSP ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + strata(I(interaction(A, B))) + RSP ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + strata(I(interaction(A, B))), + ignore_attr = TRUE ) testthat::expect_equal( h_step_rsp_formula( list(arm = "TRT", biomarker = "BM", response = "RSP", strata = "A"), control = c(control_logistic(), control_step(degree = 2)) ), - RSP ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + strata(A) + RSP ~ TRT * stats::poly(BM, degree = 2, raw = TRUE) + strata(A), + ignore_attr = TRUE ) }) @@ -395,10 +405,10 @@ testthat::test_that("h_step_rsp_est works as expected without strata", { subset = subset, x = age_vals )) - testthat::expect_is(result, "matrix") + testthat::expect_true(is.matrix(result)) testthat::expect_identical(dim(result), c(3L, 5L)) testthat::expect_identical(colnames(result), c("n", "logor", "se", "ci_lower", "ci_upper")) - testthat::expect_equal(result[, "logor"], c(2.008012, 1.025773, 0.043535), tol = 1e-6) + testthat::expect_equal(result[, "logor"], c(2.008012, 1.025773, 0.043535), tolerance = 1e-6) testthat::expect_equal(result[, "n"], rep(sum(subset), 3L)) }) @@ -424,10 +434,10 @@ testthat::test_that("h_step_rsp_est works as expected with strata", { subset = subset, x = age_vals )) - testthat::expect_is(result, "matrix") + testthat::expect_true(is.matrix(result)) testthat::expect_identical(dim(result), c(3L, 5L)) testthat::expect_identical(colnames(result), c("n", "logor", "se", "ci_lower", "ci_upper")) - testthat::expect_equal(result[, "logor"], c(1.134057, 0.511102, -0.111853), tol = 1e-6) + testthat::expect_equal(result[, "logor"], c(1.134057, 0.511102, -0.111853), tolerance = 1e-6) testthat::expect_equal(result[, "n"], rep(sum(subset), 3L)) }) diff --git a/tests/testthat/test-h_survival_biomarkers_subgroups.R b/tests/testthat/test-h_survival_biomarkers_subgroups.R index 0333dd09b7..f40c32a287 100644 --- a/tests/testthat/test-h_survival_biomarkers_subgroups.R +++ b/tests/testthat/test-h_survival_biomarkers_subgroups.R @@ -70,7 +70,7 @@ testthat::test_that("h_coxreg_mult_cont_df works as expected", { pval = c(0.483520242485134, 0.282314224545607), pval_label = c("p-value (Wald)", "p-value (Wald)") ) - testthat::expect_equal(result, expected, tol = 1e-5) + testthat::expect_equal(result, expected, tolerance = 1e-5) }) testthat::test_that("h_coxreg_mult_cont_df returns missing values if data is empty (0 rows)", { diff --git a/tests/testthat/test-h_survival_duration_subgroups.R b/tests/testthat/test-h_survival_duration_subgroups.R index 6b3e54350f..58ba31d127 100644 --- a/tests/testthat/test-h_survival_duration_subgroups.R +++ b/tests/testthat/test-h_survival_duration_subgroups.R @@ -200,7 +200,6 @@ testthat::test_that("h_split_by_subgroups works as expected with groups_lists", testthat::test_that("h_survtime_subgroups_df functions as expected with valid input and default arguments", { adtte <- adtte_local - result <- h_survtime_subgroups_df( variables = list(tte = "AVAL", is_event = "is_event", arm = "ARM", subgroups = c("SEX", "BMRKR2")), data = adtte @@ -222,7 +221,7 @@ testthat::test_that("h_survtime_subgroups_df functions as expected with valid in stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_survtime_subgroups_df functions as expected when subgroups is NULL.", { @@ -245,7 +244,7 @@ testthat::test_that("h_survtime_subgroups_df functions as expected when subgroup stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_survtime_subgroups_df works as expected with groups_lists", { @@ -291,7 +290,7 @@ testthat::test_that("h_coxph_df functions as expected with valid input and defau stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_df functions as expected with one stratification factor", { @@ -318,7 +317,7 @@ testthat::test_that("h_coxph_df functions as expected with one stratification fa stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_df functions as expected with multiple stratification factors", { @@ -344,7 +343,7 @@ testthat::test_that("h_coxph_df functions as expected with multiple stratificati stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_df functions as expected when 0 records in one group", { @@ -370,7 +369,7 @@ testthat::test_that("h_coxph_df functions as expected when 0 records in one grou stringsAsFactors = FALSE ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_subgroups_df functions as expected with valid input and default arguments", { @@ -451,14 +450,14 @@ testthat::test_that("h_coxph_subgroups_df functions as expected with valid input class = "data.frame" ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) # Test edge case where HR is (0, Inf) adtte <- adtte %>% dplyr::filter(COUNTRY %in% c("CAN", "GBR")) %>% reapply_varlabels(formatters::var_labels(adtte)) - result <- testthat::expect_warning(h_coxph_subgroups_df( + testthat::expect_warning(result <- h_coxph_subgroups_df( variables = list(tte = "AVAL", is_event = "is_event", arm = "ARM", subgroups = "COUNTRY"), data = adtte )) @@ -487,7 +486,7 @@ testthat::test_that("h_coxph_subgroups_df functions as expected with valid input class = "data.frame" ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_subgroups_df functions as expected with stratification factors", { @@ -523,7 +522,7 @@ testthat::test_that("h_coxph_subgroups_df functions as expected with stratificat class = "data.frame" ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_subgroups_df functions as expected when subgroups is NULL.", { @@ -554,7 +553,7 @@ testthat::test_that("h_coxph_subgroups_df functions as expected when subgroups i row.names = c(NA, -1L), class = "data.frame" ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("h_coxph_subgroups_df works as expected with groups_lists", { diff --git a/tests/testthat/test-kaplan_meier_plot.R b/tests/testthat/test-kaplan_meier_plot.R index e68d8694fb..de8ed07e4a 100644 --- a/tests/testthat/test-kaplan_meier_plot.R +++ b/tests/testthat/test-kaplan_meier_plot.R @@ -8,7 +8,7 @@ test_fit <- local({ testthat::test_that("h_data_plot works as expected", { data <- test_fit result <- h_data_plot(data) - testthat::expect_is(result, "tbl_df") + testthat::expect_s3_class(result, "tbl_df") testthat::expect_identical( names(result), c( @@ -24,8 +24,8 @@ testthat::test_that("h_data_plot respects the ordering of the arm variable facto dplyr::mutate(ARMCD = factor(ARMCD, levels = c("ARM B", "ARM C", "ARM A"))) %>% survival::survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) result <- h_data_plot(data) - testthat::expect_is(result, "tbl_df") - testthat::expect_is(result$strata, "factor") + testthat::expect_s3_class(result, "tbl_df") + testthat::expect_s3_class(result$strata, "factor") testthat::expect_identical(levels(result$strata), c("ARM B", "ARM C", "ARM A")) }) diff --git a/tests/testthat/test-logistic_regression.R b/tests/testthat/test-logistic_regression.R index 3666e39965..64d6281bbf 100644 --- a/tests/testthat/test-logistic_regression.R +++ b/tests/testthat/test-logistic_regression.R @@ -66,7 +66,8 @@ testthat::test_that("fit_logistic works with different response definition", { ) testthat::expect_equal( result_model$formula, - 1 - Response ~ ARMCD + 1 - Response ~ ARMCD, + ignore_attr = TRUE ) }) @@ -94,7 +95,7 @@ testthat::test_that("fit_logistic works with a single stratification variable", expected_formula <- Surv(rep(1, 20L), Response) ~ ARMCD + RACE + AGE + strata(STRATA1) result_formula <- result$formula - testthat::expect_equal(result_formula, expected_formula) + testthat::expect_equal(result_formula, expected_formula, ignore_attr = TRUE) }) testthat::test_that("fit_logistic works with two stratification variables", { @@ -122,10 +123,9 @@ testthat::test_that("fit_logistic works with two stratification variables", { expected_formula <- Surv(rep(1, 20L), Response) ~ ARMCD + RACE + AGE + strata(I(interaction(STRATA1, STRATA2))) result_formula <- result$formula - testthat::expect_equal(result_formula, expected_formula) + testthat::expect_equal(result_formula, expected_formula, ignore_attr = TRUE) }) - # h_get_interaction_vars ---- testthat::test_that("h_get_interaction_vars works as expected", { @@ -176,25 +176,26 @@ testthat::test_that("h_or_cat_interaction works as expected", { ) ) result_armcd <- h_or_cat_interaction("ARMCD", "RACE", model) - testthat::expect_is(result_armcd, "list") + testthat::expect_type(result_armcd, "list") testthat::expect_named(result_armcd, levels(data$ARMCD)[-1]) for (res in result_armcd) { - testthat::expect_is(res, "list") + testthat::expect_type(res, "list") testthat::expect_named(res, levels(droplevels(data$RACE))) } - testthat::expect_equivalent( + testthat::expect_equal( result_armcd[["ARM B"]][["ASIAN"]], list( or = 0.1503174, ci = c(0.01669928, 1.35307118) ), - tol = 1e-4 + tolerance = 1e-4, + ignore_attr = TRUE ) result_race <- h_or_cat_interaction("RACE", "ARMCD", model) - testthat::expect_is(result_race, "list") + testthat::expect_type(result_race, "list") testthat::expect_named(result_race, levels(droplevels(data$RACE))[-1]) for (res in result_race) { - testthat::expect_is(res, "list") + testthat::expect_type(res, "list") testthat::expect_named(res, levels(data$ARMCD)) } }) @@ -213,34 +214,36 @@ testthat::test_that("h_or_cont_interaction works as expected with median increme ) ) result_armcd <- h_or_cont_interaction("ARMCD", "AGE", model) - testthat::expect_is(result_armcd, "list") + testthat::expect_type(result_armcd, "list") testthat::expect_named(result_armcd, levels(data$ARMCD)[-1]) for (res in result_armcd) { - testthat::expect_is(res, "list") + testthat::expect_type(res, "list") testthat::expect_named(res, as.character(stats::median(data$AGE))) } - testthat::expect_equivalent( + testthat::expect_equal( result_armcd[["ARM B"]][["34"]], list( or = 9.284028e-05, ci = c(1.483171e-10, 5.811413e+01) ), - tol = 1e-4 + tolerance = 1e-4, + ignore_attr = TRUE ) result_age <- h_or_cont_interaction("AGE", "ARMCD", model) - testthat::expect_is(result_age, "list") + testthat::expect_type(result_age, "list") testthat::expect_named(result_age, levels(data$ARMCD)) for (res in result_age) { - testthat::expect_is(res, "list") + testthat::expect_type(res, "list") testthat::expect_named(res, c("or", "ci")) } - testthat::expect_equivalent( + testthat::expect_equal( result_age[["ARM B"]], list( or = 1.028141, ci = c(0.9286094, 1.1383411) ), - tol = 1e-4 + tolerance = 1e-4, + ignore_attr = TRUE ) }) @@ -262,10 +265,10 @@ testthat::test_that("h_or_cont_interaction works as expected with custom increme at = c(25, 30, 40), conf_level = 0.8 ) - testthat::expect_is(result_armcd, "list") + testthat::expect_type(result_armcd, "list") testthat::expect_named(result_armcd, levels(data$ARMCD)[-1]) for (res in result_armcd) { - testthat::expect_is(res, "list") + testthat::expect_type(res, "list") testthat::expect_named(res, as.character(c(25, 30, 40))) } # We are not allowed to specify increments when the interaction variable is a factor. @@ -297,7 +300,7 @@ testthat::test_that("h_or_interaction works as expected", { at = c(20, 30), conf_level = 0.9 ) - testthat::expect_is(result_cont, "list") + testthat::expect_type(result_cont, "list") model_cat <- fit_logistic( data, variables = list( @@ -312,7 +315,7 @@ testthat::test_that("h_or_interaction works as expected", { "RACE", model_cat ) - testthat::expect_is(result_cat, "list") + testthat::expect_type(result_cat, "list") }) # h_simple_term_labels ---- @@ -424,8 +427,8 @@ testthat::test_that("h_glm_simple_term_extract can extract continuous variable r ) ) - result <- testthat::expect_silent(h_glm_simple_term_extract("AGE", mod)) - expected <- data.frame( + result <- testthat::expect_silent(unlist(h_glm_simple_term_extract("AGE", mod))) + expected <- c( variable = "AGE", variable_label = "AGE", term = "AGE", @@ -434,15 +437,14 @@ testthat::test_that("h_glm_simple_term_extract can extract continuous variable r interaction_label = "", reference = "", reference_label = "", - estimate = list(0.01843522), - std_error = list(0.02429352), - df = list(1), - pvalue = list(0.4479403), + estimate = c(0.018435221512945), + std_error = c(0.0242935223263706), + df = c(1), + pvalue = c(0.447940270007941), is_variable_summary = FALSE, - is_term_summary = TRUE, - stringsAsFactors = FALSE + is_term_summary = TRUE ) - testthat::expect_equivalent(result, expected, tolerance = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001, ignore_attr = TRUE) }) # h_glm_interaction_extract ---- @@ -516,7 +518,7 @@ testthat::test_that("h_glm_interaction_extract works for continuous interaction" row.names = c(NA, -3L), class = "data.frame" ) - testthat::expect_equivalent(result, expected) + testthat::expect_equal(result, expected, ignore_attr = TRUE) }) # h_logistic_simple_terms ---- @@ -606,8 +608,8 @@ testthat::test_that("h_logistic_simple_terms can extract continuous variable res strata = "STRATA1" ) ) - result <- testthat::expect_silent(h_logistic_simple_terms("AGE", mod)) - expected <- data.frame( + result <- testthat::expect_silent(unlist(h_logistic_simple_terms("AGE", mod))) + expected <- c( variable = "AGE", variable_label = "AGE", term = "AGE", @@ -616,22 +618,20 @@ testthat::test_that("h_logistic_simple_terms can extract continuous variable res interaction_label = "", reference = "", reference_label = "", - estimate = list(0.01843522), - std_error = list(0.02429352), - df = list(1), - pvalue = list(0.4479403), + estimate = 0.018435221512945, + std_error = 0.0242935223263706, + df = 1, + pvalue = 0.447940270007941, is_variable_summary = FALSE, is_term_summary = TRUE, - odds_ratio = list(1.018606), - lcl = list(0.9712424), - ucl = list(1.06828), - stringsAsFactors = FALSE + odds_ratio = 1.01860619926387, + lcl = 0.971242395138309, + ucl = 1.06827975629198, + ci1 = 0.971242395138309, + ci2 = 1.06827975629198 ) - expected$ci <- list(c( - 0.9712424, - 1.0682798 - )) - testthat::expect_equivalent(result, expected, tolerance = 0.000001) + + testthat::expect_equal(result, expected, tolerance = 1e-4, ignore_attr = TRUE) }) # h_glm_inter_term_extract ---- @@ -755,7 +755,7 @@ testthat::test_that("h_glm_inter_term_extract works as expected with categorical ), class = "data.frame" ) - testthat::expect_equivalent(result, expected) + testthat::expect_equal(result, expected, ignore_attr = TRUE) }) testthat::test_that("h_glm_inter_term_extract works as expected with continuous interaction", { @@ -773,14 +773,14 @@ testthat::test_that("h_glm_inter_term_extract works as expected with continuous model, conf_level = 0.9 ) - testthat::expect_is(result1, "data.frame") + testthat::expect_s3_class(result1, "data.frame") result2 <- h_glm_inter_term_extract( odds_ratio_var = "AGE", interaction_var = "ARMCD", model, conf_level = 0.9 ) - testthat::expect_is(result2, "data.frame") + testthat::expect_s3_class(result2, "data.frame") }) testthat::test_that("h_logistic_inter_terms works as expected", { @@ -799,7 +799,7 @@ testthat::test_that("h_logistic_inter_terms works as expected", { fit_glm = model_cat, conf_level = 0.8 ) - testthat::expect_is(result_cat, "data.frame") + testthat::expect_s3_class(result_cat, "data.frame") testthat::expect_identical( result_cat$variable, c( @@ -832,7 +832,7 @@ testthat::test_that("h_logistic_inter_terms works as expected", { fit_glm = model_cont, conf_level = 0.8 ) - testthat::expect_is(result_cont, "data.frame") + testthat::expect_s3_class(result_cont, "data.frame") testthat::expect_identical( result_cont$term, c( @@ -934,7 +934,7 @@ testthat::test_that("tidy.glm works as expected for interaction case", { result <- broom::tidy(mod1, conf_level = 0.99) result <- result[, c("variable", "term", "interaction", "reference", "estimate", "std_error")] row.names(result) <- seq(dim(result)[1]) - testthat::expect_is(result, "data.frame") + testthat::expect_s3_class(result, "data.frame") expected <- data.frame( variable = factor( c(rep("SEX", 2), rep("ARMCD", 5), rep("AGE", 4), rep("ARMCD:AGE", 3)), @@ -1006,7 +1006,7 @@ testthat::test_that("logistic_regression_cols works as expected", { testthat::test_that("logistic_summary_by_flag works", { layout_fun <- logistic_summary_by_flag("is_variable") - testthat::expect_is(layout_fun, "function") + testthat::expect_type(layout_fun, "closure") testthat::expect_silent(layout_fun(basic_table())) }) diff --git a/tests/testthat/test-make_afun.R b/tests/testthat/test-make_afun.R index 73ddbc2529..6f607baf0c 100644 --- a/tests/testthat/test-make_afun.R +++ b/tests/testthat/test-make_afun.R @@ -17,7 +17,7 @@ testthat::test_that("make_afun works with healthy input statistics function taki ) ) - testthat::expect_is(afun, "function") + testthat::expect_type(afun, "closure") testthat::expect_identical( names(formals(afun)), names(formals(sfun)) @@ -79,7 +79,7 @@ testthat::test_that("make_afun processes additional rtables arguments correctly" ) # Make sure the function signature is correct. - testthat::expect_is(afun, "function") + testthat::expect_type(afun, "closure") testthat::expect_identical( names(formals(afun)), names(formals(sfun)) @@ -125,7 +125,7 @@ testthat::test_that("make_afun works with healthy input function taking `x`", { ) # Make sure the function signature is correct. - testthat::expect_is(afun, "function") + testthat::expect_type(afun, "closure") testthat::expect_identical( names(formals(afun)), names(formals(sfun)) @@ -184,7 +184,7 @@ testthat::test_that("make_afun produces empty cells and keeps labels when applie ) # Make sure the function signature is correct. - testthat::expect_is(afun, "function") + testthat::expect_type(afun, "closure") testthat::expect_identical( names(formals(afun)), names(formals(sfun)) diff --git a/tests/testthat/test-odds_ratio.R b/tests/testthat/test-odds_ratio.R index 9fb0205202..d566263484 100644 --- a/tests/testthat/test-odds_ratio.R +++ b/tests/testthat/test-odds_ratio.R @@ -20,7 +20,8 @@ testthat::test_that("or_glm estimates right OR and CI", { exp(stats::coef(model_fit)[-1])["grpb"], exp(stats::confint.default(model_fit, level = 0.95)["grpb", ]) ) - testthat::expect_equal(result, expected, tolerance = 1e-4, check.attributes = FALSE) + names(expected) <- c("est", "lcl", "ucl") + testthat::expect_equal(result, expected, tolerance = 1e-4, ignore_attr = FALSE) }) testthat::test_that("or_clogit estimates right OR and CI", { diff --git a/tests/testthat/test-prop_diff.R b/tests/testthat/test-prop_diff.R index 84b722012c..504e5aeb7e 100644 --- a/tests/testthat/test-prop_diff.R +++ b/tests/testthat/test-prop_diff.R @@ -9,7 +9,7 @@ testthat::test_that("`prop_diff_ha` (proportion difference by Anderson-Hauck)", diff = 0.25, diff_ci = c(-0.9195, 1.0000) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) # Edge case: Same proportion of response in A and B. @@ -21,7 +21,7 @@ testthat::test_that("`prop_diff_ha` (proportion difference by Anderson-Hauck)", diff = 0, diff_ci = c(-0.8451, 0.8451) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) }) @@ -38,7 +38,7 @@ testthat::test_that("`prop_diff_nc` (proportion difference by Newcombe)", { diff = 0.25, diff_ci = c(-0.2967, 0.6750) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) # Edge case: Same proportion of response in A and B. rsp <- c(TRUE, FALSE, TRUE, FALSE) @@ -50,7 +50,7 @@ testthat::test_that("`prop_diff_nc` (proportion difference by Newcombe)", { diff = 0, diff_ci = c(-0.3616, 0.3616) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) }) testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: with correction)", { @@ -64,7 +64,7 @@ testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: wit diff = 0.25, diff_ci = c(-0.8069, 1.0000) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) # Edge case: Same proportion of response in A and B. rsp <- c(TRUE, FALSE, TRUE, FALSE) @@ -75,7 +75,7 @@ testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: wit diff = 0, diff_ci = c(-0.9208, 0.9208) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) # Edge case: All respond in all groups. rsp <- c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) @@ -88,7 +88,7 @@ testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: wit diff = 0, diff_ci = c(-0.375, 0.375) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) }) testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: without correction)", { @@ -103,7 +103,7 @@ testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: wit diff = 0.25, diff_ci = c(-0.4319, 0.9319) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) # Edge case: Same proportion of response in A and B. rsp <- c(TRUE, FALSE, TRUE, FALSE) @@ -114,7 +114,7 @@ testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: wit diff = 0, diff_ci = c(-0.4208, 0.4208) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) # Edge case: All respond in all groups. rsp <- c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) @@ -127,7 +127,7 @@ testthat::test_that("`prop_diff_wald` (proportion difference by Wald's test: wit diff = 0, diff_ci = c(0, 0) ) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) }) testthat::test_that("`prop_diff_cmh` (proportion difference by CMH)", { @@ -160,7 +160,7 @@ testthat::test_that("`prop_diff_cmh` (proportion difference by CMH)", { ) names(expected$weights) <- names(expected$n1) <- names(expected$n2) <- levels(interaction(strata_data)) - testthat::expect_equal(result, expected, tol = 0.0001) + testthat::expect_equal(result, expected, tolerance = 0.0001) testthat::expect_warning(prop_diff_cmh( rsp = rsp[1:4], grp = grp[1:4], strata = interaction(strata_data[1:4, ]), conf_level = 0.90 @@ -203,7 +203,7 @@ testthat::test_that("prop_diff_cmh works correctly when some strata don't have b ) names(expected$weights) <- names(expected$n1) <- names(expected$n2) <- levels(interaction(strata_data))[-1] - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("`prop_strat_nc` (proportion difference by stratified Newcombe) with cmh weights", { @@ -228,8 +228,8 @@ testthat::test_that("`prop_strat_nc` (proportion difference by stratified Newcom ) # Values externally validated - expect_equal(results$diff, 0.2539, tol = 1e-4) - expect_equal(as.numeric(results$diff_ci), c(0.0347, 0.4454), tol = 1e-4) + expect_equal(results$diff, 0.2539, tolerance = 1e-4) + expect_equal(as.numeric(results$diff_ci), c(0.0347, 0.4454), tolerance = 1e-3) }) testthat::test_that("`prop_strat_nc` (proportion difference by stratified Newcombe) with wilson_h weights", { @@ -255,8 +255,8 @@ testthat::test_that("`prop_strat_nc` (proportion difference by stratified Newcom ) # Values internally checked (no reference yet) - expect_equal(results$diff, 0.2587, tol = 1e-4) - expect_equal(as.numeric(results$diff_ci), c(0.0391, 0.4501), tol = 1e-4) + expect_equal(results$diff, 0.2587, tolerance = 1e-4) + expect_equal(as.numeric(results$diff_ci), c(0.0391, 0.4501), tolerance = 1e-3) }) testthat::test_that("prop_diff_strat_nc output matches equivalent SAS function output", { diff --git a/tests/testthat/test-prune_occurrences.R b/tests/testthat/test-prune_occurrences.R index fa3f2a0b55..8feed7a046 100644 --- a/tests/testthat/test-prune_occurrences.R +++ b/tests/testthat/test-prune_occurrences.R @@ -10,7 +10,7 @@ tab <- basic_table() %>% testthat::test_that("keep_rows works in a special case identical to standard pruning", { row_condition <- !CombinationFunction(all_zero_or_na) pruning_fun <- keep_rows(row_condition) - testthat::expect_is(pruning_fun, "function") + testthat::expect_type(pruning_fun, "closure") result <- prune_table(tab, pruning_fun) expected <- prune_table(tab) testthat::expect_identical(result, expected) diff --git a/tests/testthat/test-response_subgroups.R b/tests/testthat/test-response_subgroups.R index f3542686c5..b8b6883e10 100644 --- a/tests/testthat/test-response_subgroups.R +++ b/tests/testthat/test-response_subgroups.R @@ -16,7 +16,6 @@ preprocess_adrs <- function(adrs, n_records = 20) { adrs } - adrs_100 <- adrs_raw %>% preprocess_adrs(n_records = 100) @@ -57,8 +56,7 @@ testthat::test_that("extract_rsp_subgroups functions as expected with valid inpu stringsAsFactors = FALSE ) ) - - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("extract_rsp_subgroups functions as expected with NULL subgroups", { @@ -95,8 +93,7 @@ testthat::test_that("extract_rsp_subgroups functions as expected with NULL subgr stringsAsFactors = FALSE ) ) - - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("extract_rsp_subgroups works as expected with groups_lists", { @@ -166,8 +163,7 @@ testthat::test_that("extract_rsp_subgroups functions as expected with strata", { stringsAsFactors = FALSE ) ) - - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("a_response_subgroups functions as expected with valid input", { @@ -231,7 +227,6 @@ testthat::test_that("tabulate_rsp_subgroups functions as expected with valid inp ), .Dim = c(9L, 9L) ) - testthat::expect_equal(result_matrix, expected_matrix) }) @@ -341,12 +336,12 @@ testthat::test_that("tabulate_rsp_subgroups functions as expected with NULL subg testthat::test_that("tabulate_rsp_subgroups functions as expected when 0 obs in one arm", { adrs <- adrs_200 - df <- testthat::expect_warning(extract_rsp_subgroups( + suppressWarnings(testthat::expect_warning(df <- extract_rsp_subgroups( variables = list(rsp = "rsp", arm = "ARM", subgroups = "RACE"), data = adrs, method = "chisq", conf_level = 0.95 - )) + ))) result <- basic_table() %>% tabulate_rsp_subgroups( @@ -396,6 +391,5 @@ testthat::test_that("d_rsp_subgroups_colvars functions as expected with valid in pval = "p-value (Chi-Squared Test)" ) ) - testthat::expect_equal(result, expected) }) diff --git a/tests/testthat/test-rtables_access.R b/tests/testthat/test-rtables_access.R index 218cac22b3..fa4c47b2da 100644 --- a/tests/testthat/test-rtables_access.R +++ b/tests/testthat/test-rtables_access.R @@ -115,5 +115,5 @@ testthat::test_that("h_content_first_row works as expected", { summarize_row_groups() %>% build_table(DM) result <- h_content_first_row(simple_tab) - testthat::expect_is(result, "ContentRow") + testthat::expect_s4_class(result, "ContentRow") }) diff --git a/tests/testthat/test-score_occurrences.R b/tests/testthat/test-score_occurrences.R index 28a2e682ba..e549f6ab9c 100644 --- a/tests/testthat/test-score_occurrences.R +++ b/tests/testthat/test-score_occurrences.R @@ -142,7 +142,7 @@ testthat::test_that("score_occurrences functions as expected with empty analysis testthat::test_that("score_occurrences_cols functions as expected", { score_col_c <- score_occurrences_cols(col_names = "C") - testthat::expect_is(score_col_c, "function") + testthat::expect_type(score_col_c, "closure") sorted_table <- full_table %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_col_c) @@ -180,7 +180,7 @@ testthat::test_that("score_occurrences_subtable functions as expected", { prune_table() score_subtable_all <- score_occurrences_subtable(col_names = names(full_table_dfae)) - testthat::expect_is(score_subtable_all, "function") + testthat::expect_type(score_subtable_all, "closure") sorted_table <- full_table_dfae %>% sort_at_path(path = c("AEBODSYS"), scorefun = score_subtable_all, decreasing = FALSE) @@ -214,7 +214,7 @@ testthat::test_that("score_occurrences_cont_cols functions as expected", { build_table(df = dfae) score_cont_cols <- score_occurrences_cont_cols(col_names = c("A", "B")) - testthat::expect_is(score_cont_cols, "function") + testthat::expect_type(score_cont_cols, "closure") sorted_table <- full_table_dfae %>% sort_at_path(path = c("AESUPSYS"), scorefun = score_cont_cols, decreasing = TRUE) diff --git a/tests/testthat/test-split_cols_by_groups.R b/tests/testthat/test-split_cols_by_groups.R index bf686886da..59004a76f7 100644 --- a/tests/testthat/test-split_cols_by_groups.R +++ b/tests/testthat/test-split_cols_by_groups.R @@ -23,7 +23,7 @@ testthat::test_that("groups_list_to_df works as expected", { # combine_groups ---- testthat::test_that("combine_groups combines character vectors", { - result <- testthat::expect_warning(combine_groups(fct = c("A", "B", "C"))) + testthat::expect_warning(result <- combine_groups(fct = c("A", "B", "C"))) expected <- list(A = "A", `B/C` = c("B", "C")) testthat::expect_identical(result, expected) }) @@ -189,8 +189,8 @@ testthat::test_that("split_cols_by_groups manages combinations of columns with r # combine_counts ---- testthat::test_that("combine_counts combines character vectors", { fct <- c("A", "A", "A", "B", "B", "C") - grp <- testthat::expect_warning(combine_groups(fct = fct)) - result <- testthat::expect_warning(combine_counts(fct, grp)) + testthat::expect_warning(grp <- combine_groups(fct = fct)) + testthat::expect_warning(result <- combine_counts(fct, grp)) expected <- c(A = 3, `B/C` = 3) testthat::expect_identical(result, expected) }) diff --git a/tests/testthat/test-summarize_change.R b/tests/testthat/test-summarize_change.R index 4c3a1f24c8..8200533ca3 100644 --- a/tests/testthat/test-summarize_change.R +++ b/tests/testthat/test-summarize_change.R @@ -85,7 +85,7 @@ testthat::test_that("s_change_from_baseline handles NA in baseline values", { geom_cv = c(geom_cv = NA_real_) ) - testthat::expect_equal(result, expected, tol = 1e-6) + testthat::expect_equal(result, expected, tolerance = 1e-6) }) testthat::test_that("s_change_from_baseline handles baseline substitution", { diff --git a/tests/testthat/test-summarize_glm_count.R b/tests/testthat/test-summarize_glm_count.R index 68c8b44753..851cb636af 100644 --- a/tests/testthat/test-summarize_glm_count.R +++ b/tests/testthat/test-summarize_glm_count.R @@ -369,12 +369,11 @@ testthat::test_that("s_glm_count works with no reference group selected.", { rate_ratio_ci = formatters::with_label(c(0.6120999, 0.5219551, 1.7749272, 1.5564142), "95% CI"), pval = formatters::with_label(c(0.8786994, 0.7093289), "p-value") ) - testthat::expect_equal(result, expected, tolerance = 0.0000001) }) testthat::test_that("s_glm_count fails wrong inputs", { - testthat::expect_error( + testthat::expect_error(s_glm_count( df = anl %>% filter(ARMCD == "ARM B"), .df_row = anl, @@ -384,13 +383,11 @@ testthat::test_that("s_glm_count fails wrong inputs", { conf_level = 0.95, distribution = "quasipoisson", rate_mean_method = "ppmeans" - ) + )) }) - - testthat::test_that("glm_count fails when negative binomial distribution is selected.", { - testthat::expect_error( + testthat::expect_error(glm_count( df = anl %>% filter(ARMCD == "ARM B"), .df_row = anl, @@ -400,7 +397,7 @@ testthat::test_that("glm_count fails when negative binomial distribution is sele conf_level = 0.95, distribution = "negbin", rate_mean_method = "ppmeans" - ) + )) }) testthat::test_that("summarize_glm_count works with healthy inputs", { diff --git a/tests/testthat/test-summarize_variables.R b/tests/testthat/test-summarize_variables.R index eae0e945a1..b4a5204073 100644 --- a/tests/testthat/test-summarize_variables.R +++ b/tests/testthat/test-summarize_variables.R @@ -46,7 +46,7 @@ testthat::test_that("s_summary return NA for x length 0L", { geom_mean_ci = formatters::with_label(c(mean_ci_lwr = NA_real_, mean_ci_upr = NA_real_), "Geometric Mean 95% CI"), geom_cv = c(geom_cv = NA_real_) ) - testthat::expect_equivalent(result, expected) + testthat::expect_equal(result, expected, ignore_attr = TRUE) }) testthat::test_that("s_summary handles NA", { @@ -79,7 +79,7 @@ testthat::test_that("s_summary handles NA", { geom_mean_ci = formatters::with_label(c(mean_ci_lwr = NA_real_, mean_ci_upr = NA_real_), "Geometric Mean 95% CI"), geom_cv = c(geom_cv = NA_real_) ) - testthat::expect_equivalent(result, expected) + testthat::expect_equal(result, expected, ignore_attr = TRUE) # With `na.rm = FALSE`. result <- s_summary(x, na.rm = FALSE) @@ -108,7 +108,7 @@ testthat::test_that("s_summary handles NA", { geom_mean_ci = formatters::with_label(c(mean_ci_lwr = NA_real_, mean_ci_upr = NA_real_), "Geometric Mean 95% CI"), geom_cv = c(geom_cv = NA_real_) ) - testthat::expect_equivalent(result, expected) + testthat::expect_equal(result, expected, ignore_attr = TRUE) }) testthat::test_that("s_summary returns right results for n = 2", { @@ -142,7 +142,7 @@ testthat::test_that("s_summary returns right results for n = 2", { ), geom_cv = c(geom_cv = 52.10922) ) - testthat::expect_equivalent(result, expected, tolerance = .00001) + testthat::expect_equal(result, expected, tolerance = .00001, ignore_attr = TRUE) }) testthat::test_that("s_summary returns right results for n = 8", { @@ -173,7 +173,7 @@ testthat::test_that("s_summary returns right results for n = 8", { geom_mean_ci = formatters::with_label(c(mean_ci_lwr = 2.456211, mean_ci_upr = 9.547283), "Geometric Mean 95% CI"), geom_cv = c(geom_cv = 96.61307) ) - testthat::expect_equivalent(result, expected, tolerance = .00001) + testthat::expect_equal(result, expected, tolerance = .00001, ignore_attr = TRUE) }) testthat::test_that("s_summary works with factors", { @@ -295,7 +295,7 @@ testthat::test_that("s_summary works with factors and different denominator choi testthat::test_that("s_summary works with characters by converting to character", { x <- c("Female", "Male", "Female", "Male", "Male", "Unknown", "Unknown", "Unknown", "Unknown") - result <- testthat::expect_warning(s_summary(x, denom = "N_row", .N_row = 20, .var = "SEX")) + testthat::expect_warning(result <- s_summary(x, denom = "N_row", .N_row = 20, .var = "SEX")) expected <- s_summary(factor(x), denom = "N_row", .N_row = 20) testthat::expect_identical(result, expected) @@ -304,7 +304,7 @@ testthat::test_that("s_summary works with characters by converting to character" testthat::test_that("s_summary works with characters by converting to character and handling empty strings", { x <- c("Female", "Male", "Female", "Male", "Male", "", "Unknown", "Unknown", "Unknown", "Unknown") - result <- testthat::expect_warning(s_summary(x, .var = "foo", na.rm = FALSE, denom = "N_row", .N_row = 10)) + testthat::expect_warning(result <- s_summary(x, .var = "foo", na.rm = FALSE, denom = "N_row", .N_row = 10)) expected <- list( n = 10L, count = list( @@ -327,7 +327,7 @@ testthat::test_that("s_summary works with characters by converting to character testthat::test_that("s_summary does not work for length 0 character vectors", { x <- character() - testthat::expect_warning(testthat::expect_error(s_summary(x, denom = "n", .var = "foo"))) + suppressWarnings(testthat::expect_error(s_summary(x, denom = "n", .var = "foo"))) }) testthat::test_that("s_summary works with logical vectors", { @@ -571,7 +571,7 @@ testthat::test_that("`summarize_vars` works with character input and gives the s l <- basic_table() %>% summarize_vars(vars = "foo") - result <- testthat::expect_warning(build_table(l, dta)) + testthat::expect_warning(result <- build_table(l, dta)) dta_factor <- dta %>% dplyr::mutate(foo = factor(foo)) @@ -590,7 +590,7 @@ testthat::test_that("`summarize_vars` does not work with sparse character input l <- basic_table() %>% split_cols_by("boo") %>% summarize_vars(vars = "foo") - testthat::expect_error(testthat::expect_warning(build_table(l, dta))) + suppressWarnings(testthat::expect_error(testthat::expect_warning(build_table(l, dta)))) # But when converting to factor, it works because we keep the levels information across columns. dta_factor <- dta %>% diff --git a/tests/testthat/test-survival_duration_subgroups.R b/tests/testthat/test-survival_duration_subgroups.R index 2804851151..7fe0dc6eea 100644 --- a/tests/testthat/test-survival_duration_subgroups.R +++ b/tests/testthat/test-survival_duration_subgroups.R @@ -184,7 +184,7 @@ testthat::test_that("extract_survival_subgroups functions as expected with valid row.names = c(NA, -6L), class = "data.frame" ) ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("extract_survival_subgroups works as expected with groups_lists", { @@ -263,7 +263,7 @@ testthat::test_that("extract_survival_subgroups functions as expected with NULL class = "data.frame" ) ) - testthat::expect_equal(result, expected, tol = 0.000001) + testthat::expect_equal(result, expected, tolerance = 0.000001) }) testthat::test_that("a_survival_subgroups functions as expected with valid input", { @@ -356,10 +356,10 @@ testthat::test_that("tabulate_survival_subgroups functions as expected with extr dplyr::slice(1:30) %>% reapply_varlabels(formatters::var_labels(adtte_local)) - df <- testthat::expect_warning(extract_survival_subgroups( + suppressWarnings(testthat::expect_warning(df <- extract_survival_subgroups( variables = list(tte = "AVAL", is_event = "is_event", arm = "ARM", subgroups = "REGION1"), data = adtte - )) + ))) result <- basic_table() %>% tabulate_survival_subgroups(df, time_unit = adtte$AVALU[1]) diff --git a/tests/testthat/test-table_adat03.R b/tests/testthat/test-table_adat03.R index c95cab4448..2e9e48c4f3 100644 --- a/tests/testthat/test-table_adat03.R +++ b/tests/testthat/test-table_adat03.R @@ -67,23 +67,6 @@ testthat::test_that("ADAT03 is produced correctly", { fnotes_at_path(result, rowpath = NULL, colpath = c("multivars", "AVAL")) <- "footnote1" # nolint fnotes_at_path(result, rowpath = NULL, colpath = c("multivars", "AVAL_LT")) <- "footnote2" # nolint - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Treatment Group", " Visit", "", "", "A: Drug X (N=1206)", "Day 1", " ", "Day 2", " ", - "C: Combination (N=2112)", "Day 1", " ", "Day 2", " ", "Overall", - "", "Total Number", "of Measurable", " Samples {1}", "", "", "938", "", "268", "", "", "1584", "", "528", "3318", - "", "", "", "Mean", "", "", "8.227e+00", "", "1.344e+01", "", "", "1.469e+01", "", "2.018e+01", "1.363e+01", - "", "", "", "SD", "", "", "7.351e+00", "", "1.351e+00", "", "", "1.237e+01", "", "7.129e+00", "1.059e+01", - "", "", "", "Median", "", "", "1.131e+01", "", "1.330e+01", "", "", "1.451e+01", "", "1.888e+01", "1.377e+01", - "", "", "", "Minimum", "", "", "0.000e+00", "", "1.075e+01", "", "", "0.000e+00", "", "1.073e+01", "0.000e+00", - "", "", "", "Maximum", "", "", "1.986e+01", "", "1.646e+01", "", "", "3.947e+01", "", "3.259e+01", "3.947e+01", - "", "", "", "CV (%)", "", "", "89.4", "", "10.0", "", "", "84.3", "", "35.3", "77.7", - "", "", "", "Geometric Mean", "", "", "NA", "", "1.338e+01", "", "", "NA", "", "1.891e+01", "NA", - "", "Samples with", "Concentration", "≤ 15μg/mL {2}", "", "", "738 (78.7%)", "", "228 (85.1%)", "", "", - "836 (52.8%)", "", "210 (39.8%)", "2012 (60.6%)" - ), - .Dim = c(15L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet01.R b/tests/testthat/test-table_aet01.R index 0fa999ad71..363b19f910 100644 --- a/tests/testthat/test-table_aet01.R +++ b/tests/testthat/test-table_aet01.R @@ -90,34 +90,8 @@ testthat::test_that("Safety Summary Variant 1 works as expected", { result_adae[3:nrow(result_adae), ] ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one adverse event", - "Total AEs", "Total number of deaths", "Total number of patients withdrawn from study due to an AE", - "Total number of patients with at least one", "AE with fatal outcome", - "Serious AE", "Serious AE leading to withdrawal from treatment", - "Serious AE leading to dose modification/interruption", "Related Serious AE", - "AE leading to withdrawal from treatment", "AE leading to dose modification/interruption", - "Related AE", "Related AE leading to withdrawal from treatment", - "Related AE leading to dose modification/interruption", "Grade 3-5 AE", - "A: Drug X", "(N=134)", "122 (91.0%)", "609", "25 (18.66%)", - "3 (2.24%)", "", "76 (56.7%)", "104 (77.6%)", "9 (6.7%)", - "22 (16.4%)", "76 (56.7%)", "27 (20.1%)", "66 (49.3%)", "105 (78.4%)", - "6 (4.5%)", "29 (21.6%)", "109 (81.3%)", "B: Placebo", "(N=134)", - "123 (91.8%)", "622", "23 (17.16%)", "6 (4.48%)", "", "70 (52.2%)", - "101 (75.4%)", "6 (4.5%)", "26 (19.4%)", "70 (52.2%)", "26 (19.4%)", - "76 (56.7%)", "108 (80.6%)", "12 (9.0%)", "38 (28.4%)", "104 (77.6%)", - "C: Combination", "(N=132)", "120 (90.9%)", "703", "22 (16.67%)", - "5 (3.79%)", "", "75 (56.8%)", "99 (75.0%)", "11 (8.3%)", "29 (22.0%)", - "75 (56.8%)", "30 (22.7%)", "74 (56.1%)", "109 (82.6%)", - "8 (6.1%)", "38 (28.8%)", "109 (82.6%)" - ), - .Dim = c(18L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Safety Summary Variant 2 (with Medical Concepts Section) works as expected", { @@ -236,38 +210,8 @@ testthat::test_that("Safety Summary Variant 2 (with Medical Concepts Section) wo result_adae[3:nrow(result_adae), ] ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one adverse event", - "Total AEs", "Total number of deaths", "Total number of patients withdrawn from study due to an AE", - "Total number of patients with at least one", "AE with fatal outcome", - "Serious AE", "Serious AE leading to withdrawal from treatment", - "Serious AE leading to dose modification/interruption", "Related Serious AE", - "AE leading to withdrawal from treatment", "AE leading to dose modification/interruption", - "Related AE", "Related AE leading to withdrawal from treatment", - "Related AE leading to dose modification/interruption", "Grade 3-5 AE", - "Total number of patients with at least one", "C.1.1.1.3/B.2.2.3.1 AESI (BROAD)", - "SMQ 02 Reference Name", "D.2.1.5.3/A.1.1.1.1 AESI", "A: Drug X", - "(N=134)", "122 (91.0%)", "609", "25 (18.66%)", "3 (2.24%)", - "", "76 (56.7%)", "104 (77.6%)", "9 (6.7%)", "22 (16.4%)", - "76 (56.7%)", "27 (20.1%)", "66 (49.3%)", "105 (78.4%)", - "6 (4.5%)", "29 (21.6%)", "109 (81.3%)", "", "72 (53.7%)", - "0", "74 (55.2%)", "B: Placebo", "(N=134)", "123 (91.8%)", - "622", "23 (17.16%)", "6 (4.48%)", "", "70 (52.2%)", "101 (75.4%)", - "6 (4.5%)", "26 (19.4%)", "70 (52.2%)", "26 (19.4%)", "76 (56.7%)", - "108 (80.6%)", "12 (9.0%)", "38 (28.4%)", "104 (77.6%)", "", - "79 (59.0%)", "0", "80 (59.7%)", "C: Combination", "(N=132)", - "120 (90.9%)", "703", "22 (16.67%)", "5 (3.79%)", "", "75 (56.8%)", - "99 (75.0%)", "11 (8.3%)", "29 (22.0%)", "75 (56.8%)", "30 (22.7%)", - "74 (56.1%)", "109 (82.6%)", "8 (6.1%)", "38 (28.8%)", "109 (82.6%)", - "", "75 (56.8%)", "0", "87 (65.9%)" - ), - .Dim = c(22L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Safety Summary Variant 3 (with Modified Rows) works as expected", { @@ -358,25 +302,8 @@ testthat::test_that("Safety Summary Variant 3 (with Modified Rows) works as expe result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one adverse event", - "Total AEs", "Total number of deaths", "Total number of patients withdrawn from study due to an AE", - "Total number of patients withdrawn informed consent", "Total number of patients with at least one", - "AE with fatal outcome", "Serious AE", "AE leading to withdrawal from treatment", - "Related AE", "Grade 3-5 AE", "Grade 4/5 AE", "A: Drug X", "(N=134)", - "122 (91.0%)", "609", "25 (18.66%)", "3 (2.24%)", "1 (0.75%)", - "", "76 (56.7%)", "104 (77.6%)", "27 (20.1%)", "105 (78.4%)", - "109 (81.3%)", "91 (67.9%)", "B: Placebo", "(N=134)", "123 (91.8%)", - "622", "23 (17.16%)", "6 (4.48%)", "1 (0.75%)", "", "70 (52.2%)", - "101 (75.4%)", "26 (19.4%)", "108 (80.6%)", "104 (77.6%)", - "90 (67.2%)", "C: Combination", "(N=132)", "120 (90.9%)", "703", - "22 (16.67%)", "5 (3.79%)", "1 (0.76%)", "", "75 (56.8%)", "99 (75.0%)", - "30 (22.7%)", "109 (82.6%)", "109 (82.6%)", "93 (70.5%)" - ), - .Dim = c(14L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Safety Summary Variant 4 (with Rows Counting Events and Additional Sections) works as expected", { @@ -488,33 +415,6 @@ testthat::test_that("Safety Summary Variant 4 (with Rows Counting Events and Add result_adae[3:nrow(result_adae), ] ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one adverse event", - "Total AEs", "Total number of deaths", "Total number of patients withdrawn from study due to an AE", - "Total number of patients with at least one", "AE with fatal outcome", - "Serious AE", "AE leading to withdrawal from treatment", "AE leading to dose modification/interruption", - "Related AE", "Grade 3-5 AE", "Total number of unique preferred terms which are", - "Serious AE", "AE leading to dose modification/interruption", - "Related AE", "Grade 3-5 AE", "Grade 4/5", "Total number of adverse events which are", - "Serious AE", "AE leading to dose modification/interruption", - "Related AE", "Grade 3-5 AE", "Grade 4/5", "A: Drug X", "(N=134)", - "122 (91.0%)", "609", "25 (18.66%)", "3 (2.24%)", "", "76 (56.7%)", - "104 (77.6%)", "27 (20.1%)", "66 (49.3%)", "105 (78.4%)", - "109 (81.3%)", "", "4", "8", "5", "5", "3", "", "249", "116", - "282", "303", "172", "B: Placebo", "(N=134)", "123 (91.8%)", - "622", "23 (17.16%)", "6 (4.48%)", "", "70 (52.2%)", "101 (75.4%)", - "26 (19.4%)", "76 (56.7%)", "108 (80.6%)", "104 (77.6%)", - "", "4", "8", "5", "5", "3", "", "255", "122", "299", "291", - "174", "C: Combination", "(N=132)", "120 (90.9%)", "703", "22 (16.67%)", - "5 (3.79%)", "", "75 (56.8%)", "99 (75.0%)", "30 (22.7%)", "74 (56.1%)", - "109 (82.6%)", "109 (82.6%)", "", "4", "8", "5", "5", "3", - "", "282", "137", "336", "327", "197" - ), - .Dim = c(25L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet02.R b/tests/testthat/test-table_aet02.R index 89a2651435..4c6b63f7bd 100644 --- a/tests/testthat/test-table_aet02.R +++ b/tests/testthat/test-table_aet02.R @@ -38,118 +38,8 @@ testthat::test_that("AET02 variant 1 is produced correctly", { sort_at_path(path = c("AEBODSYS"), scorefun = cont_n_onecol(4)) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", - "Total number of patients with at least one adverse event", - "Overall total number of events", - "cl A.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd A.1.1.1.1", - "dcd A.1.1.1.2", - "cl B.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.2.2.3.1", - "dcd B.2.1.2.1", - "cl D.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.1.1.1.1", - "dcd D.1.1.4.2", - "cl D.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.2.1.5.3", - "cl B.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.1.1.1.1", - "cl C.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd C.2.1.2.1", - "cl C.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd C.1.1.1.3", "A: Drug X", - "(N=134)", "122 (91.0%)", - "609", "", - "78 (58.2%)", "132", - "50 (37.3%)", "48 (35.8%)", - "", "79 (59.0%)", - "129", "48 (35.8%)", - "49 (36.6%)", "", - "79 (59.0%)", "127", - "50 (37.3%)", "48 (35.8%)", - "", "47 (35.1%)", - "62", "47 (35.1%)", - "", "47 (35.1%)", - "56", "47 (35.1%)", - "", "35 (26.1%)", - "48", "35 (26.1%)", - "", "43 (32.1%)", - "55", "43 (32.1%)", - "B: Placebo", "(N=134)", - "123 (91.8%)", "622", - "", "75 (56.0%)", - "130", "45 (33.6%)", - "48 (35.8%)", "", - "74 (55.2%)", "138", - "54 (40.3%)", "44 (32.8%)", - "", "67 (50.0%)", - "106", "42 (31.3%)", - "42 (31.3%)", "", - "58 (43.3%)", "72", - "58 (43.3%)", "", - "49 (36.6%)", "60", - "49 (36.6%)", "", - "48 (35.8%)", "53", - "48 (35.8%)", "", - "46 (34.3%)", "63", - "46 (34.3%)", "C: Combination", - "(N=132)", "120 (90.9%)", - "703", "", - "89 (67.4%)", "160", - "63 (47.7%)", "50 (37.9%)", - "", "85 (64.4%)", - "143", "51 (38.6%)", - "52 (39.4%)", "", - "80 (60.6%)", "135", - "51 (38.6%)", "50 (37.9%)", - "", "57 (43.2%)", - "74", "57 (43.2%)", - "", "43 (32.6%)", - "62", "43 (32.6%)", - "", "55 (41.7%)", - "65", "55 (41.7%)", - "", "43 (32.6%)", - "64", "43 (32.6%)", - "All Patients", "(N=400)", - "365 (91.2%)", "1934", - "", "242 (60.5%)", - "422", "158 (39.5%)", - "146 (36.5%)", "", - "238 (59.5%)", "410", - "153 (38.2%)", "145 (36.2%)", - "", "226 (56.5%)", - "368", "143 (35.8%)", - "140 (35.0%)", "", - "162 (40.5%)", "208", - "162 (40.5%)", "", - "139 (34.8%)", "178", - "139 (34.8%)", "", - "138 (34.5%)", "166", - "138 (34.5%)", "", - "132 (33.0%)", "182", - "132 (33.0%)" - ), - .Dim = c(35L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Testing pagination with not repeated Total number of patients pag_result <- paginate_table(result, lpp = 20) @@ -201,189 +91,8 @@ testthat::test_that("AET02 variant 2 is produced correctly", { sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences) %>% sort_at_path(path = c("AEBODSYS"), scorefun = cont_n_onecol(4)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", - "", - "Total number of patients with at least one adverse event", - "Overall total number of events", - "cl A.1", - "Total number of patients with at least one adverse event", - "dcd A.1.1.1.1", - "dcd A.1.1.1.2", - "Total number of events", - "cl B.2", - "Total number of patients with at least one adverse event", - "dcd B.2.2.3.1", - "dcd B.2.1.2.1", - "Total number of events", - "cl D.1", - "Total number of patients with at least one adverse event", - "dcd D.1.1.1.1", - "dcd D.1.1.4.2", - "Total number of events", - "cl D.2", - "Total number of patients with at least one adverse event", - "dcd D.2.1.5.3", - "Total number of events", - "cl B.1", - "Total number of patients with at least one adverse event", - "dcd B.1.1.1.1", - "Total number of events", - "cl C.2", - "Total number of patients with at least one adverse event", - "dcd C.2.1.2.1", - "Total number of events", - "cl C.1", - "Total number of patients with at least one adverse event", - "dcd C.1.1.1.3", - "Total number of events", - "A: Drug X", - "(N=134)", - "122 (91.0%)", - "609", - "", - "78 (58.2%)", - "50 (37.3%)", - "48 (35.8%)", - "132", - "", - "79 (59.0%)", - "48 (35.8%)", - "49 (36.6%)", - "129", - "", - "79 (59.0%)", - "50 (37.3%)", - "48 (35.8%)", - "127", - "", - "47 (35.1%)", - "47 (35.1%)", - "62", - "", - "47 (35.1%)", - "47 (35.1%)", - "56", - "", - "35 (26.1%)", - "35 (26.1%)", - "48", - "", - "43 (32.1%)", - "43 (32.1%)", - "55", - "B: Placebo", - "(N=134)", - "123 (91.8%)", - "622", - "", - "75 (56.0%)", - "45 (33.6%)", - "48 (35.8%)", - "130", - "", - "74 (55.2%)", - "54 (40.3%)", - "44 (32.8%)", - "138", - "", - "67 (50.0%)", - "42 (31.3%)", - "42 (31.3%)", - "106", - "", - "58 (43.3%)", - "58 (43.3%)", - "72", - "", - "49 (36.6%)", - "49 (36.6%)", - "60", - "", - "48 (35.8%)", - "48 (35.8%)", - "53", - "", - "46 (34.3%)", - "46 (34.3%)", - "63", - "C: Combination", - "(N=132)", - "120 (90.9%)", - "703", - "", - "89 (67.4%)", - "63 (47.7%)", - "50 (37.9%)", - "160", - "", - "85 (64.4%)", - "51 (38.6%)", - "52 (39.4%)", - "143", - "", - "80 (60.6%)", - "51 (38.6%)", - "50 (37.9%)", - "135", - "", - "57 (43.2%)", - "57 (43.2%)", - "74", - "", - "43 (32.6%)", - "43 (32.6%)", - "62", - "", - "55 (41.7%)", - "55 (41.7%)", - "65", - "", - "43 (32.6%)", - "43 (32.6%)", - "64", - "All Patients", - "(N=400)", - "365 (91.2%)", - "1934", - "", - "242 (60.5%)", - "158 (39.5%)", - "146 (36.5%)", - "422", - "", - "238 (59.5%)", - "153 (38.2%)", - "145 (36.2%)", - "410", - "", - "226 (56.5%)", - "143 (35.8%)", - "140 (35.0%)", - "368", - "", - "162 (40.5%)", - "162 (40.5%)", - "208", - "", - "139 (34.8%)", - "139 (34.8%)", - "178", - "", - "138 (34.5%)", - "138 (34.5%)", - "166", - "", - "132 (33.0%)", - "132 (33.0%)", - "182" - ), - .Dim = c(35L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 3 is produced correctly", { @@ -436,262 +145,8 @@ testthat::test_that("AET02 variant 3 is produced correctly", { sort_at_path(path = c("AEBODSYS", "*", "AEHLT"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("AEBODSYS", "*", "AEHLT", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", - "", - "Total number of patients with at least one adverse event", - "Overall total number of events", - "cl A.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt A.1.1.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd A.1.1.1.1", - "dcd A.1.1.1.2", - "cl B.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt B.2.2.3", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.2.2.3.1", - "hlt B.2.1.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.2.1.2.1", - "cl D.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt D.1.1.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.1.1.1.1", - "hlt D.1.1.4", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.1.1.4.2", - "cl D.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt D.2.1.5", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.2.1.5.3", - "cl B.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt B.1.1.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.1.1.1.1", - "cl C.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt C.2.1.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd C.2.1.2.1", - "cl C.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "hlt C.1.1.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd C.1.1.1.3", - "A: Drug X", - "(N=134)", - "122 (91.0%)", - "609", - "", - "78 (58.2%)", - "132", - "", - "78 (58.2%)", - "132", - "50 (37.3%)", - "48 (35.8%)", - "", - "79 (59.0%)", - "129", - "", - "48 (35.8%)", - "64", - "48 (35.8%)", - "", - "49 (36.6%)", - "65", - "49 (36.6%)", - "", - "79 (59.0%)", - "127", - "", - "50 (37.3%)", - "61", - "50 (37.3%)", - "", - "48 (35.8%)", - "66", - "48 (35.8%)", - "", - "47 (35.1%)", - "62", - "", - "47 (35.1%)", - "62", - "47 (35.1%)", - "", - "47 (35.1%)", - "56", - "", - "47 (35.1%)", - "56", - "47 (35.1%)", - "", - "35 (26.1%)", - "48", - "", - "35 (26.1%)", - "48", - "35 (26.1%)", - "", - "43 (32.1%)", - "55", - "", - "43 (32.1%)", - "55", - "43 (32.1%)", - "B: Placebo", - "(N=134)", - "123 (91.8%)", - "622", - "", - "75 (56.0%)", - "130", - "", - "75 (56.0%)", - "130", - "45 (33.6%)", - "48 (35.8%)", - "", - "74 (55.2%)", - "138", - "", - "54 (40.3%)", - "76", - "54 (40.3%)", - "", - "44 (32.8%)", - "62", - "44 (32.8%)", - "", - "67 (50.0%)", - "106", - "", - "42 (31.3%)", - "51", - "42 (31.3%)", - "", - "42 (31.3%)", - "55", - "42 (31.3%)", - "", - "58 (43.3%)", - "72", - "", - "58 (43.3%)", - "72", - "58 (43.3%)", - "", - "49 (36.6%)", - "60", - "", - "49 (36.6%)", - "60", - "49 (36.6%)", - "", - "48 (35.8%)", - "53", - "", - "48 (35.8%)", - "53", - "48 (35.8%)", - "", - "46 (34.3%)", - "63", - "", - "46 (34.3%)", - "63", - "46 (34.3%)", - "C: Combination", - "(N=132)", - "120 (90.9%)", - "703", - "", - "89 (67.4%)", - "160", - "", - "89 (67.4%)", - "160", - "63 (47.7%)", - "50 (37.9%)", - "", - "85 (64.4%)", - "143", - "", - "51 (38.6%)", - "77", - "51 (38.6%)", - "", - "52 (39.4%)", - "66", - "52 (39.4%)", - "", - "80 (60.6%)", - "135", - "", - "51 (38.6%)", - "71", - "51 (38.6%)", - "", - "50 (37.9%)", - "64", - "50 (37.9%)", - "", - "57 (43.2%)", - "74", - "", - "57 (43.2%)", - "74", - "57 (43.2%)", - "", - "43 (32.6%)", - "62", - "", - "43 (32.6%)", - "62", - "43 (32.6%)", - "", - "55 (41.7%)", - "65", - "", - "55 (41.7%)", - "65", - "55 (41.7%)", - "", - "43 (32.6%)", - "64", - "", - "43 (32.6%)", - "64", - "43 (32.6%)" - ), - .Dim = c(62L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 4 is produced correctly", { @@ -715,42 +170,8 @@ testthat::test_that("AET02 variant 4 is produced correctly", { result <- result %>% sort_at_path(path = c("AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", - "Total number of patients with at least one adverse event", "Total number of events", - "dcd D.2.1.5.3", "dcd A.1.1.1.1", - "dcd B.2.2.3.1", "dcd A.1.1.1.2", - "dcd B.2.1.2.1", "dcd D.1.1.1.1", - "dcd D.1.1.4.2", "dcd B.1.1.1.1", - "dcd C.2.1.2.1", "dcd C.1.1.1.3", - "A: Drug X", "(N=134)", - "122 (91.0%)", "609", - "47 (35.1%)", "50 (37.3%)", - "48 (35.8%)", "48 (35.8%)", - "49 (36.6%)", "50 (37.3%)", - "48 (35.8%)", "47 (35.1%)", - "35 (26.1%)", "43 (32.1%)", - "B: Placebo", "(N=134)", - "123 (91.8%)", "622", - "58 (43.3%)", "45 (33.6%)", - "54 (40.3%)", "48 (35.8%)", - "44 (32.8%)", "42 (31.3%)", - "42 (31.3%)", "49 (36.6%)", - "48 (35.8%)", "46 (34.3%)", - "C: Combination", "(N=132)", - "120 (90.9%)", "703", - "57 (43.2%)", "63 (47.7%)", - "51 (38.6%)", "50 (37.9%)", - "52 (39.4%)", "51 (38.6%)", - "50 (37.9%)", "43 (32.6%)", - "55 (41.7%)", "43 (32.6%)" - ), - .Dim = c(14L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 5 is produced correctly", { @@ -789,154 +210,8 @@ testthat::test_that("AET02 variant 5 is produced correctly", { sort_at_path(path = c("AEBODSYS"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", - "", - "Total number of patients with at least one adverse event", - "Overall total number of events", - "cl A.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd A.1.1.1.2", - "dcd A.1.1.1.1", - "cl B.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.2.2.3.1", - "dcd B.2.1.2.1", - "cl D.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.1.1.1.1", - "dcd D.1.1.4.2", - "cl D.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd D.2.1.5.3", - "cl B.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd B.1.1.1.1", - "cl C.1", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd C.1.1.1.3", - "cl C.2", - "Total number of patients with at least one adverse event", - "Total number of events", - "dcd C.2.1.2.1", - "A: Drug X", - "(N=134)", - "122 (91.0%)", - "609", - "", - "78 (58.2%)", - "132", - "48 (35.8%)", - "50 (37.3%)", - "", - "79 (59.0%)", - "129", - "48 (35.8%)", - "49 (36.6%)", - "", - "79 (59.0%)", - "127", - "50 (37.3%)", - "48 (35.8%)", - "", - "47 (35.1%)", - "62", - "47 (35.1%)", - "", - "47 (35.1%)", - "56", - "47 (35.1%)", - "", - "43 (32.1%)", - "55", - "43 (32.1%)", - "", - "35 (26.1%)", - "48", - "35 (26.1%)", - "B: Placebo", - "(N=134)", - "123 (91.8%)", - "622", - "", - "75 (56.0%)", - "130", - "48 (35.8%)", - "45 (33.6%)", - "", - "74 (55.2%)", - "138", - "54 (40.3%)", - "44 (32.8%)", - "", - "67 (50.0%)", - "106", - "42 (31.3%)", - "42 (31.3%)", - "", - "58 (43.3%)", - "72", - "58 (43.3%)", - "", - "49 (36.6%)", - "60", - "49 (36.6%)", - "", - "46 (34.3%)", - "63", - "46 (34.3%)", - "", - "48 (35.8%)", - "53", - "48 (35.8%)", - "C: Combination", - "(N=132)", - "0", - "0", - "", - "0", - "0", - "0", - "0", - "", - "0", - "0", - "0", - "0", - "", - "0", - "0", - "0", - "0", - "", - "0", - "0", - "0", - "", - "0", - "0", - "0", - "", - "0", - "0", - "0", - "", - "0", - "0", - "0" - ), - .Dim = c(35L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 6 is produced correctly", { @@ -968,24 +243,8 @@ testthat::test_that("AET02 variant 6 is produced correctly", { row_condition <- has_fraction_in_any_col(atleast = 0.40, col_names = names(table(adsl$ARM))) result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl A.1", "dcd A.1.1.1.1", - "cl B.2", "dcd B.2.2.3.1", "cl D.2", "dcd D.2.1.5.3", - "cl C.2", "dcd C.2.1.2.1", "A: Drug X", "(N=134)", - "", "50 (37.3%)", "", "48 (35.8%)", - "", "47 (35.1%)", "", "35 (26.1%)", - "B: Placebo", "(N=134)", "", "45 (33.6%)", - "", "54 (40.3%)", "", "58 (43.3%)", - "", "48 (35.8%)", "C: Combination", "(N=132)", - "", "63 (47.7%)", "", "51 (38.6%)", - "", "57 (43.2%)", "", "55 (41.7%)" - ), - .Dim = c(10L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 7 is produced correctly", { @@ -1031,28 +290,8 @@ testthat::test_that("AET02 variant 7 is produced correctly", { row_condition <- has_fraction_in_any_col(atleast = 0.40, col_names = names(table(adsl$ARM))) result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl A.1", "hlt A.1.1.1", - "dcd A.1.1.1.1", "cl B.2", "hlt B.2.2.3", "dcd B.2.2.3.1", - "cl D.2", "hlt D.2.1.5", "dcd D.2.1.5.3", "cl C.2", - "hlt C.2.1.2", "dcd C.2.1.2.1", "A: Drug X", "(N=134)", - "", "", "50 (37.3%)", "", - "", "48 (35.8%)", "", "", - "47 (35.1%)", "", "", "35 (26.1%)", - "B: Placebo", "(N=134)", "", "", - "45 (33.6%)", "", "", "54 (40.3%)", - "", "", "58 (43.3%)", "", - "", "48 (35.8%)", "C: Combination", "(N=132)", - "", "", "63 (47.7%)", "", - "", "51 (38.6%)", "", "", - "57 (43.2%)", "", "", "55 (41.7%)" - ), - .Dim = c(14L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 8 is produced correctly", { @@ -1084,24 +323,8 @@ testthat::test_that("AET02 variant 8 is produced correctly", { row_condition <- has_fraction_in_any_col(atleast = 0.40, col_names = names(table(adsl$ARM))) result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl A.1", "dcd A.1.1.1.1", - "cl B.2", "dcd B.2.2.3.1", "cl D.2", "dcd D.2.1.5.3", - "cl C.2", "dcd C.2.1.2.1", "A: Drug X", "(N=134)", - "", "50 (37.3%)", "", "48 (35.8%)", - "", "47 (35.1%)", "", "35 (26.1%)", - "B: Placebo", "(N=134)", "", "45 (33.6%)", - "", "54 (40.3%)", "", "58 (43.3%)", - "", "48 (35.8%)", "C: Combination", "(N=132)", - "", "63 (47.7%)", "", "51 (38.6%)", - "", "57 (43.2%)", "", "55 (41.7%)" - ), - .Dim = c(10L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 9 is produced correctly", { @@ -1133,26 +356,8 @@ testthat::test_that("AET02 variant 9 is produced correctly", { row_condition <- has_count_in_any_col(atleast = 52, col_names = names(table(adsl$ARM))) result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl A.1", - "dcd A.1.1.1.1", "cl B.2", "dcd B.2.2.3.1", "dcd B.2.1.2.1", "cl D.2", - "dcd D.2.1.5.3", "cl C.2", "dcd C.2.1.2.1", - "A: Drug X", "(N=134)", "", "50 (37.3%)", "", - "48 (35.8%)", "49 (36.6%)", "", - "47 (35.1%)", "", "35 (26.1%)", "B: Placebo", "(N=134)", - "", "45 (33.6%)", "", - "54 (40.3%)", "44 (32.8%)", "", "58 (43.3%)", "", - "48 (35.8%)", "C: Combination", "(N=132)", - "", "63 (47.7%)", "", "51 (38.6%)", "52 (39.4%)", - "", "57 (43.2%)", "", - "55 (41.7%)" - ), - .Dim = c(11, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 10 is produced correctly", { @@ -1184,28 +389,8 @@ testthat::test_that("AET02 variant 10 is produced correctly", { row_condition <- has_fractions_difference(atleast = 0.05, col_names = names(table(adsl$ARM))) result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl A.1", - "dcd A.1.1.1.1", "cl B.2", "dcd B.2.1.2.1", "cl D.1", "dcd D.1.1.1.1", - "dcd D.1.1.4.2", "cl D.2", "dcd D.2.1.5.3", - "cl C.2", "dcd C.2.1.2.1", "A: Drug X", "(N=134)", "", - "50 (37.3%)", "", "49 (36.6%)", - "", "50 (37.3%)", "48 (35.8%)", "", "47 (35.1%)", - "", "35 (26.1%)", "B: Placebo", - "(N=134)", "", "45 (33.6%)", "", "44 (32.8%)", - "", "42 (31.3%)", "42 (31.3%)", - "", "58 (43.3%)", "", "48 (35.8%)", "C: Combination", - "(N=132)", "", "63 (47.7%)", - "", "52 (39.4%)", "", "51 (38.6%)", "50 (37.9%)", - "", "57 (43.2%)", "", - "55 (41.7%)" - ), - .Dim = c(13L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 11 is produced correctly", { @@ -1237,20 +422,8 @@ testthat::test_that("AET02 variant 11 is produced correctly", { row_condition <- has_fraction_in_cols(atleast = 0.40, col_names = c("B: Placebo")) result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl B.2", "dcd B.2.2.3.1", - "cl D.2", "dcd D.2.1.5.3", "A: Drug X", "(N=134)", - "", "48 (35.8%)", "", "47 (35.1%)", - "B: Placebo", "(N=134)", "", "54 (40.3%)", - "", "58 (43.3%)", "C: Combination", "(N=132)", - "", "51 (38.6%)", "", "57 (43.2%)" - ), - .Dim = c(6L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02 variant 12 is produced correctly", { @@ -1298,20 +471,6 @@ testthat::test_that("AET02 variant 12 is produced correctly", { result <- prune_table(result, keep_rows(row_condition)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "cl A.1", "dcd A.1.1.1.1", "cl D.1", "dcd D.1.1.1.1", - "cl D.2", "dcd D.2.1.5.3", "cl C.2", "dcd C.2.1.2.1", - "A: Drug X", "(N=134)", "", "50 (37.3%)", "", "50 (37.3%)", - "", "47 (35.1%)", "", "35 (26.1%)", - "B: Placebo", "(N=134)", "", "45 (33.6%)", "", "42 (31.3%)", - "", "58 (43.3%)", "", "48 (35.8%)", - "C: Combination", "(N=132)", "", "63 (47.7%)", "", "51 (38.6%)", - "", "57 (43.2%)", "", "55 (41.7%)" - ), - .Dim = c(10L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet02_smq.R b/tests/testthat/test-table_aet02_smq.R index a8e2ca70c4..59f7424008 100644 --- a/tests/testthat/test-table_aet02_smq.R +++ b/tests/testthat/test-table_aet02_smq.R @@ -48,30 +48,8 @@ testthat::test_that("AET02SMQ variant 1 is produced correctly", { sort_at_path(path = c("AE_GRP"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("AE_GRP", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", - "Total number of patients with at least one adverse event", "SMQ01NAM", - "Total number of patients with at least one adverse event", "Overall total number of events", - "dcd B.2.2.3.1", "dcd C.1.1.1.3", - "A: Drug X", "(N=134)", - "72 (53.7%)", "", - "72 (53.7%)", "119", - "48 (35.8%)", "43 (32.1%)", - "B: Placebo", "(N=134)", - "79 (59.0%)", "", - "79 (59.0%)", "139", - "54 (40.3%)", "46 (34.3%)", - "C: Combination", "(N=132)", - "75 (56.8%)", "", - "75 (56.8%)", "141", - "51 (38.6%)", "43 (32.6%)" - ), - .Dim = c(8L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET02SMQ variant 2 is produced correctly", { @@ -109,64 +87,6 @@ testthat::test_that("AET02SMQ variant 2 is produced correctly", { sort_at_path(path = c("AE_GRP"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("AE_GRP", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", - "", - "Total number of patients with at least one adverse event", - "CQ01NAM", - "Total number of patients with at least one adverse event", - "Overall total number of events", - "dcd D.2.1.5.3", - "dcd A.1.1.1.1", - "SMQ01NAM", - "Total number of patients with at least one adverse event", - "Overall total number of events", - "dcd B.2.2.3.1", - "dcd C.1.1.1.3", - "A: Drug X", - "(N=134)", - "95 (70.9%)", - "", - "74 (55.2%)", - "126", - "47 (35.1%)", - "50 (37.3%)", - "", - "72 (53.7%)", - "119", - "48 (35.8%)", - "43 (32.1%)", - "B: Placebo", - "(N=134)", - "103 (76.9%)", - "", - "80 (59.7%)", - "134", - "58 (43.3%)", - "45 (33.6%)", - "", - "79 (59.0%)", - "139", - "54 (40.3%)", - "46 (34.3%)", - "C: Combination", - "(N=132)", - "108 (81.8%)", - "", - "87 (65.9%)", - "162", - "57 (43.2%)", - "63 (47.7%)", - "", - "75 (56.8%)", - "141", - "51 (38.6%)", - "43 (32.6%)" - ), - .Dim = c(13L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet03.R b/tests/testthat/test-table_aet03.R index f101194029..e4da1657a9 100644 --- a/tests/testthat/test-table_aet03.R +++ b/tests/testthat/test-table_aet03.R @@ -53,69 +53,10 @@ testthat::test_that("AET03 variant 1 is produced correctly", { decreasing = TRUE ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "- Any Intensity -", "MILD", "MODERATE", - "SEVERE", "LIFE THREATENING", "cl A.1", "- Any Intensity -", - "MILD", "MODERATE", "LIFE THREATENING", "dcd A.1.1.1.1", "- Any Intensity -", - "MILD", "LIFE THREATENING", "dcd A.1.1.1.2", "- Any Intensity -", - "MODERATE", "LIFE THREATENING", "cl B.2", "- Any Intensity -", - "MILD", "MODERATE", "LIFE THREATENING", "dcd B.2.2.3.1", "- Any Intensity -", - "MILD", "dcd B.2.1.2.1", "- Any Intensity -", "MODERATE", "LIFE THREATENING", - "cl D.1", "- Any Intensity -", "MODERATE", "SEVERE", "LIFE THREATENING", - "dcd D.1.1.1.1", "- Any Intensity -", "SEVERE", "LIFE THREATENING", - "dcd D.1.1.4.2", "- Any Intensity -", "MODERATE", "LIFE THREATENING", - "cl D.2", "- Any Intensity -", "MILD", "LIFE THREATENING", "dcd D.2.1.5.3", - "- Any Intensity -", "MILD", "LIFE THREATENING", "cl B.1", "- Any Intensity -", - "SEVERE", "LIFE THREATENING", "dcd B.1.1.1.1", "- Any Intensity -", - "SEVERE", "LIFE THREATENING", "cl C.2", "- Any Intensity -", - "MODERATE", "LIFE THREATENING", "dcd C.2.1.2.1", "- Any Intensity -", - "MODERATE", "LIFE THREATENING", "cl C.1", "- Any Intensity -", - "SEVERE", "dcd C.1.1.1.3", "- Any Intensity -", "SEVERE", "A: Drug X", - "(N=134)", "122 (91.0%)", "7 (5.2%)", "23 (17.2%)", "91 (67.9%)", - "1 (0.7%)", "", "78 (58.2%)", "30 (22.4%)", "47 (35.1%)", "1 (0.7%)", - "", "50 (37.3%)", "50 (37.3%)", "0", "", "48 (35.8%)", "47 (35.1%)", - "1 (0.7%)", "", "79 (59.0%)", "30 (22.4%)", "48 (35.8%)", "1 (0.7%)", - "", "48 (35.8%)", "48 (35.8%)", "", "49 (36.6%)", "48 (35.8%)", - "1 (0.7%)", "", "79 (59.0%)", "28 (20.9%)", "50 (37.3%)", "1 (0.7%)", - "", "50 (37.3%)", "50 (37.3%)", "0", "", "48 (35.8%)", "47 (35.1%)", - "1 (0.7%)", "", "47 (35.1%)", "47 (35.1%)", "0", "", "47 (35.1%)", - "47 (35.1%)", "0", "", "47 (35.1%)", "47 (35.1%)", "0", - "", "47 (35.1%)", "47 (35.1%)", "0", "", "35 (26.1%)", "35 (26.1%)", - "0", "", "35 (26.1%)", "35 (26.1%)", "0", "", "43 (32.1%)", - "43 (32.1%)", "", "43 (32.1%)", "43 (32.1%)", "B: Placebo", "(N=134)", - "123 (91.8%)", "9 (6.7%)", "24 (17.9%)", "89 (66.4%)", "1 (0.7%)", - "", "75 (56.0%)", "27 (20.1%)", "48 (35.8%)", "0", "", "45 (33.6%)", - "45 (33.6%)", "0", "", "48 (35.8%)", "48 (35.8%)", "0", - "", "74 (55.2%)", "30 (22.4%)", "44 (32.8%)", "0", "", "54 (40.3%)", - "54 (40.3%)", "", "44 (32.8%)", "44 (32.8%)", "0", "", "67 (50.0%)", - "25 (18.7%)", "42 (31.3%)", "0", "", "42 (31.3%)", "42 (31.3%)", - "0", "", "42 (31.3%)", "42 (31.3%)", "0", "", "58 (43.3%)", - "58 (43.3%)", "0", "", "58 (43.3%)", "58 (43.3%)", "0", - "", "49 (36.6%)", "48 (35.8%)", "1 (0.7%)", "", "49 (36.6%)", - "48 (35.8%)", "1 (0.7%)", "", "48 (35.8%)", "48 (35.8%)", "0", - "", "48 (35.8%)", "48 (35.8%)", "0", "", "46 (34.3%)", "46 (34.3%)", - "", "46 (34.3%)", "46 (34.3%)", "C: Combination", "(N=132)", - "120 (90.9%)", "4 (3.0%)", "23 (17.4%)", "91 (68.9%)", "2 (1.5%)", - "", "89 (67.4%)", "39 (29.5%)", "49 (37.1%)", "1 (0.8%)", "", - "63 (47.7%)", "62 (47.0%)", "1 (0.8%)", "", "50 (37.9%)", "49 (37.1%)", - "1 (0.8%)", "", "85 (64.4%)", "33 (25.0%)", "51 (38.6%)", "1 (0.8%)", - "", "51 (38.6%)", "51 (38.6%)", "", "52 (39.4%)", "51 (38.6%)", - "1 (0.8%)", "", "80 (60.6%)", "29 (22.0%)", "49 (37.1%)", "2 (1.5%)", - "", "51 (38.6%)", "50 (37.9%)", "1 (0.8%)", "", "50 (37.9%)", - "49 (37.1%)", "1 (0.8%)", "", "57 (43.2%)", "56 (42.4%)", "1 (0.8%)", - "", "57 (43.2%)", "56 (42.4%)", "1 (0.8%)", "", "43 (32.6%)", - "43 (32.6%)", "0", "", "43 (32.6%)", "43 (32.6%)", "0", - "", "55 (41.7%)", "54 (40.9%)", "1 (0.8%)", "", "55 (41.7%)", - "54 (40.9%)", "1 (0.8%)", "", "43 (32.6%)", "43 (32.6%)", "", - "43 (32.6%)", "43 (32.6%)" - ), - .Dim = c(75L, 4L) - ) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) - testthat::expect_identical(result_matrix, expected_matrix) + result_matrix <- to_string_matrix(result) # Pagination also works (and sorting) pag_result <- paginate_table(result, lpp = 15) diff --git a/tests/testthat/test-table_aet04.R b/tests/testthat/test-table_aet04.R index 887dd14016..57eb7143f6 100644 --- a/tests/testthat/test-table_aet04.R +++ b/tests/testthat/test-table_aet04.R @@ -98,92 +98,8 @@ testthat::test_that("AET04 variant 1 is produced correctly", { decreasing = TRUE ) - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "————————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) ", - "Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) ", - "1 7 (5.2%) 9 (6.7%) 4 (3.0%) ", - "2 6 (4.5%) 10 (7.5%) 7 (5.3%) ", - "Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) ", - "3 18 (13.4%) 14 (10.4%) 16 (12.1%) ", - "4 15 (11.2%) 20 (14.9%) 18 (13.6%) ", - "Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " 1 30 (22.4%) 27 (20.1%) 39 (29.5%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " dcd A.1.1.1.2 ", - " - Any Grade - 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " Grade 1-2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - "cl B.2 ", - " - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) ", - " Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " 1 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " dcd B.2.2.3.1 ", - " - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " 1 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " dcd B.2.1.2.1 ", - " - Any Grade - 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - "cl D.1 ", - " - Any Grade - 79 (59.0%) 67 (50.0%) 80 (60.6%) ", - " Grade 3-4 29 (21.6%) 25 (18.7%) 29 (22.0%) ", - " 3 29 (21.6%) 25 (18.7%) 29 (22.0%) ", - " Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " dcd D.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " dcd D.1.1.4.2 ", - " - Any Grade - 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - " Grade 3-4 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - " 3 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - "cl B.1 ", - " - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " dcd B.1.1.1.1 ", - " - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - "cl C.1 ", - " - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " 4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " dcd C.1.1.1.3 ", - " - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " 4 43 (32.1%) 46 (34.3%) 43 (32.6%) " - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination also works (and sorting) testthat::expect_silent( @@ -247,92 +163,8 @@ testthat::test_that("AET04 variant 2 is produced correctly (Fill in of Treatment decreasing = TRUE ) - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "———————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 0 0 ", - "Grade 1-2 13 (9.7%) 0 0 ", - "1 7 (5.2%) 0 0 ", - "2 6 (4.5%) 0 0 ", - "Grade 3-4 33 (24.6%) 0 0 ", - "3 18 (13.4%) 0 0 ", - "4 15 (11.2%) 0 0 ", - "Grade 5 76 (56.7%) 0 0 ", - "cl B.2 ", - " - Any Grade - 79 (59.0%) 0 0 ", - " Grade 1-2 30 (22.4%) 0 0 ", - " 1 30 (22.4%) 0 0 ", - " Grade 3-4 49 (36.6%) 0 0 ", - " 3 49 (36.6%) 0 0 ", - " dcd B.2.1.2.1 ", - " - Any Grade - 49 (36.6%) 0 0 ", - " Grade 3-4 49 (36.6%) 0 0 ", - " 3 49 (36.6%) 0 0 ", - " dcd B.2.2.3.1 ", - " - Any Grade - 48 (35.8%) 0 0 ", - " Grade 1-2 48 (35.8%) 0 0 ", - " 1 48 (35.8%) 0 0 ", - "cl D.1 ", - " - Any Grade - 79 (59.0%) 0 0 ", - " Grade 3-4 29 (21.6%) 0 0 ", - " 3 29 (21.6%) 0 0 ", - " Grade 5 50 (37.3%) 0 0 ", - " dcd D.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 0 0 ", - " Grade 5 50 (37.3%) 0 0 ", - " dcd D.1.1.4.2 ", - " - Any Grade - 48 (35.8%) 0 0 ", - " Grade 3-4 48 (35.8%) 0 0 ", - " 3 48 (35.8%) 0 0 ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 0 0 ", - " Grade 1-2 78 (58.2%) 0 0 ", - " 1 30 (22.4%) 0 0 ", - " 2 48 (35.8%) 0 0 ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 0 0 ", - " Grade 1-2 50 (37.3%) 0 0 ", - " 1 50 (37.3%) 0 0 ", - " dcd A.1.1.1.2 ", - " - Any Grade - 48 (35.8%) 0 0 ", - " Grade 1-2 48 (35.8%) 0 0 ", - " 2 48 (35.8%) 0 0 ", - "cl B.1 ", - " - Any Grade - 47 (35.1%) 0 0 ", - " Grade 5 47 (35.1%) 0 0 ", - " dcd B.1.1.1.1 ", - " - Any Grade - 47 (35.1%) 0 0 ", - " Grade 5 47 (35.1%) 0 0 ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 0 0 ", - " Grade 1-2 47 (35.1%) 0 0 ", - " 1 47 (35.1%) 0 0 ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 0 0 ", - " Grade 1-2 47 (35.1%) 0 0 ", - " 1 47 (35.1%) 0 0 ", - "cl C.1 ", - " - Any Grade - 43 (32.1%) 0 0 ", - " Grade 3-4 43 (32.1%) 0 0 ", - " 4 43 (32.1%) 0 0 ", - " dcd C.1.1.1.3 ", - " - Any Grade - 43 (32.1%) 0 0 ", - " Grade 3-4 43 (32.1%) 0 0 ", - " 4 43 (32.1%) 0 0 ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 0 0 ", - " Grade 1-2 35 (26.1%) 0 0 ", - " 2 35 (26.1%) 0 0 ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 0 0 ", - " Grade 1-2 35 (26.1%) 0 0 ", - " 2 35 (26.1%) 0 0 " - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination also works (and sorting) testthat::expect_silent( @@ -388,92 +220,8 @@ testthat::test_that("AET04 variant 3 is produced correctly (Fill in of Grades)", ) %>% trim_rows() - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "————————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) ", - "Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) ", - "1 7 (5.2%) 9 (6.7%) 4 (3.0%) ", - "2 6 (4.5%) 10 (7.5%) 7 (5.3%) ", - "Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) ", - "3 18 (13.4%) 14 (10.4%) 16 (12.1%) ", - "4 15 (11.2%) 20 (14.9%) 18 (13.6%) ", - "Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " 1 30 (22.4%) 27 (20.1%) 39 (29.5%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " dcd A.1.1.1.2 ", - " - Any Grade - 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " Grade 1-2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - "cl B.2 ", - " - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) ", - " Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " 1 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " dcd B.2.2.3.1 ", - " - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " 1 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " dcd B.2.1.2.1 ", - " - Any Grade - 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - "cl D.1 ", - " - Any Grade - 79 (59.0%) 67 (50.0%) 80 (60.6%) ", - " Grade 3-4 29 (21.6%) 25 (18.7%) 29 (22.0%) ", - " 3 29 (21.6%) 25 (18.7%) 29 (22.0%) ", - " Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " dcd D.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " Grade 5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " dcd D.1.1.4.2 ", - " - Any Grade - 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - " Grade 3-4 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - " 3 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - "cl B.1 ", - " - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " dcd B.1.1.1.1 ", - " - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " Grade 5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - "cl C.1 ", - " - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " 4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " dcd C.1.1.1.3 ", - " - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " Grade 3-4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " 4 43 (32.1%) 46 (34.3%) 43 (32.6%) " - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination also works (and sorting) testthat::expect_silent( @@ -540,95 +288,8 @@ testthat::test_that("AET04 variant 4 is produced correctly (Collapsing of Grades decreasing = TRUE ) - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "————————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) ", - "Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) ", - "1 7 (5.2%) 9 (6.7%) 4 (3.0%) ", - "2 6 (4.5%) 10 (7.5%) 7 (5.3%) ", - "Grade 3-5 109 (81.3%) 104 (77.6%) 109 (82.6%) ", - "3 18 (13.4%) 14 (10.4%) 16 (12.1%) ", - "4 15 (11.2%) 20 (14.9%) 18 (13.6%) ", - "5 76 (56.7%) 70 (52.2%) 75 (56.8%) ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " 1 30 (22.4%) 27 (20.1%) 39 (29.5%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " dcd A.1.1.1.2 ", - " - Any Grade - 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " Grade 1-2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - "cl B.2 ", - " - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) ", - " Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " 1 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " Grade 3-5 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " dcd B.2.2.3.1 ", - " - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " 1 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " dcd B.2.1.2.1 ", - " - Any Grade - 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " Grade 3-5 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - "cl D.1 ", - " - Any Grade - 79 (59.0%) 67 (50.0%) 80 (60.6%) ", - " Grade 3-5 79 (59.0%) 67 (50.0%) 80 (60.6%) ", - " 3 29 (21.6%) 25 (18.7%) 29 (22.0%) ", - " 5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " dcd D.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " Grade 3-5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " 5 50 (37.3%) 42 (31.3%) 51 (38.6%) ", - " dcd D.1.1.4.2 ", - " - Any Grade - 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - " Grade 3-5 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - " 3 48 (35.8%) 42 (31.3%) 50 (37.9%) ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - "cl B.1 ", - " - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " Grade 3-5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " 5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " dcd B.1.1.1.1 ", - " - Any Grade - 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " Grade 3-5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - " 5 47 (35.1%) 49 (36.6%) 43 (32.6%) ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - "cl C.1 ", - " - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " Grade 3-5 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " 4 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " dcd C.1.1.1.3 ", - " - Any Grade - 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " Grade 3-5 43 (32.1%) 46 (34.3%) 43 (32.6%) ", - " 4 43 (32.1%) 46 (34.3%) 43 (32.6%) " - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination works testthat::expect_silent( @@ -639,8 +300,8 @@ testthat::test_that("AET04 variant 4 is produced correctly (Collapsing of Grades # No test done for variant 5 (Using Worst Grade Flags from ADAE) since it's similar to # variant 1 (just pre-processing the data). -testthat::test_that("AET04 variant 6 is produced correctly (with an - Incidence Rate of at Least 5%, totals restricted)", { +testthat::test_that( + "AET04 variant 6 is produced correctly (with an Incidence Rate of at Least 5%, totals restricted)", { # Simple wrapper to return subset ADAE to a threshold of xx%. get_adae_trimmed <- function(adsl, adae, cutoff_rate) { n_per_arm <- adsl %>% @@ -719,50 +380,8 @@ testthat::test_that("AET04 variant 6 is produced correctly (with an decreasing = TRUE ) - result_matrix <- to_string_matrix(result, TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "———————————————————————————————————————————————————————————————", - "- Any Grade - 92 (68.7%) 104 (77.6%) 107 (81.1%) ", - "Grade 1-2 92 (68.7%) 104 (77.6%) 107 (81.1%) ", - "1 57 (42.5%) 56 (41.8%) 52 (39.4%) ", - "2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - "cl A.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - "cl B.2 ", - " - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " 1 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " dcd B.2.2.3.1 ", - " - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " 1 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) " - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination works testthat::expect_silent( @@ -793,39 +412,8 @@ testthat::test_that("AET04 variant 8 is produced correctly (with an Incidence Ra result <- prune_table(raw_result, keep_rows(my_row_condition(row_condition))) - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "————————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) ", - "Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) ", - "1 7 (5.2%) 9 (6.7%) 4 (3.0%) ", - "2 6 (4.5%) 10 (7.5%) 7 (5.3%) ", - "Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) ", - "3 18 (13.4%) 14 (10.4%) 16 (12.1%) ", - "4 15 (11.2%) 20 (14.9%) 18 (13.6%) ", - "Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " 1 30 (22.4%) 27 (20.1%) 39 (29.5%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) " - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination works testthat::expect_silent( @@ -840,40 +428,8 @@ testthat::test_that("AET04 variant 9 is produced correctlyb(with a Difference in result <- prune_table(raw_result, keep_rows(my_row_condition(row_condition))) - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "————————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) ", - "Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) ", - "1 7 (5.2%) 9 (6.7%) 4 (3.0%) ", - "2 6 (4.5%) 10 (7.5%) 7 (5.3%) ", - "Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) ", - "3 18 (13.4%) 14 (10.4%) 16 (12.1%) ", - "4 15 (11.2%) 20 (14.9%) 18 (13.6%) ", - "Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " 1 30 (22.4%) 27 (20.1%) 39 (29.5%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) " - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination works testthat::expect_silent( @@ -887,65 +443,15 @@ testthat::test_that("AET04 variant 9 is produced correctlyb(with a Difference in # there are no terms left. testthat::test_that( - "AET04 variant 11 is produced correctly - (with an Incidence Rate of at Least X%, all SOCs w/o preferred terms removed)", + "AET04 variant 11 is produced correctly (with Incidence Rate of at Least X%, all SOCs w/o preferred terms removed)", { cutoff <- 0.4 row_condition <- has_fraction_in_any_col(atleast = cutoff, col_names = levels(adsl$ACTARM)) result <- prune_table(raw_result, keep_rows(my_row_condition(row_condition))) - result_matrix <- to_string_matrix(result, with_spaces = TRUE) - - expected_matrix <- c( - " A: Drug X B: Placebo C: Combination", - " (N=134) (N=134) (N=132) ", - "————————————————————————————————————————————————————————————————", - "- Any Grade - 122 (91.0%) 123 (91.8%) 120 (90.9%) ", - "Grade 1-2 13 (9.7%) 19 (14.2%) 11 (8.3%) ", - "1 7 (5.2%) 9 (6.7%) 4 (3.0%) ", - "2 6 (4.5%) 10 (7.5%) 7 (5.3%) ", - "Grade 3-4 33 (24.6%) 34 (25.4%) 34 (25.8%) ", - "3 18 (13.4%) 14 (10.4%) 16 (12.1%) ", - "4 15 (11.2%) 20 (14.9%) 18 (13.6%) ", - "Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) ", - "cl A.1 ", - " - Any Grade - 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " Grade 1-2 78 (58.2%) 75 (56.0%) 89 (67.4%) ", - " 1 30 (22.4%) 27 (20.1%) 39 (29.5%) ", - " 2 48 (35.8%) 48 (35.8%) 50 (37.9%) ", - " dcd A.1.1.1.1 ", - " - Any Grade - 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " Grade 1-2 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - " 1 50 (37.3%) 45 (33.6%) 63 (47.7%) ", - "cl B.2 ", - " - Any Grade - 79 (59.0%) 74 (55.2%) 85 (64.4%) ", - " Grade 1-2 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " 1 30 (22.4%) 30 (22.4%) 33 (25.0%) ", - " Grade 3-4 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " 3 49 (36.6%) 44 (32.8%) 52 (39.4%) ", - " dcd B.2.2.3.1 ", - " - Any Grade - 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " Grade 1-2 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - " 1 48 (35.8%) 54 (40.3%) 51 (38.6%) ", - "cl D.2 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " dcd D.2.1.5.3 ", - " - Any Grade - 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " Grade 1-2 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - " 1 47 (35.1%) 58 (43.3%) 57 (43.2%) ", - "cl C.2 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " dcd C.2.1.2.1 ", - " - Any Grade - 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " Grade 1-2 35 (26.1%) 48 (35.8%) 55 (41.7%) ", - " 2 35 (26.1%) 48 (35.8%) 55 (41.7%) " - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Pagination works testthat::expect_silent( diff --git a/tests/testthat/test-table_aet04_pi.R b/tests/testthat/test-table_aet04_pi.R index b5d2cf8e40..8d060ebb84 100644 --- a/tests/testthat/test-table_aet04_pi.R +++ b/tests/testthat/test-table_aet04_pi.R @@ -57,48 +57,9 @@ testthat::test_that("AET04_PI full table is produced correctly", { scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)), decreasing = TRUE ) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "Total number of patients with at least one adverse event", - "dcd A.1.1.1.1", "dcd A.1.1.1.2", "cl B.2", "Total number of patients with at least one adverse event", - "dcd B.2.2.3.1", "dcd B.2.1.2.1", "cl D.1", "Total number of patients with at least one adverse event", - "dcd D.1.1.1.1", "dcd D.1.1.4.2", "cl D.2", "Total number of patients with at least one adverse event", - "dcd D.2.1.5.3", "cl B.1", "Total number of patients with at least one adverse event", - "dcd B.1.1.1.1", "cl C.2", "Total number of patients with at least one adverse event", - "dcd C.2.1.2.1", "cl C.1", "Total number of patients with at least one adverse event", - "dcd C.1.1.1.3", "A: Drug X", "Any Grade (%)", "(N=134)", "", - "78 (58.2%)", "37", "36", "", "79 (59.0%)", "36", "37", "", "79 (59.0%)", - "37", "36", "", "47 (35.1%)", "35", "", "47 (35.1%)", "35", "", - "35 (26.1%)", "26", "", "43 (32.1%)", "32", "A: Drug X", "Grade 3-4 (%)", - "(N=134)", "", "0", "0", "0", "", "49 (36.6%)", "0", "37", "", - "48 (35.8%)", "0", "36", "", "0", "0", "", "0", "0", "", "0", - "0", "", "43 (32.1%)", "32", "A: Drug X", "Grade 5 (%)", "(N=134)", - "", "0", "0", "0", "", "0", "0", "0", "", "50 (37.3%)", "37", - "0", "", "0", "0", "", "47 (35.1%)", "35", "", "0", "0", "", - "0", "0", "B: Placebo", "Any Grade (%)", "(N=134)", "", "75 (56.0%)", - "34", "36", "", "74 (55.2%)", "40", "33", "", "67 (50.0%)", "31", - "31", "", "58 (43.3%)", "43", "", "49 (36.6%)", "37", "", "48 (35.8%)", - "36", "", "46 (34.3%)", "34", "B: Placebo", "Grade 3-4 (%)", - "(N=134)", "", "0", "0", "0", "", "44 (32.8%)", "0", "33", "", - "42 (31.3%)", "0", "31", "", "0", "0", "", "0", "0", "", "0", - "0", "", "46 (34.3%)", "34", "B: Placebo", "Grade 5 (%)", "(N=134)", - "", "0", "0", "0", "", "0", "0", "0", "", "42 (31.3%)", "31", - "0", "", "0", "0", "", "49 (36.6%)", "37", "", "0", "0", "", - "0", "0", "C: Combination", "Any Grade (%)", "(N=132)", "", "89 (67.4%)", - "48", "38", "", "85 (64.4%)", "39", "39", "", "80 (60.6%)", "39", - "38", "", "57 (43.2%)", "43", "", "43 (32.6%)", "33", "", "55 (41.7%)", - "42", "", "43 (32.6%)", "33", "C: Combination", "Grade 3-4 (%)", - "(N=132)", "", "0", "0", "0", "", "52 (39.4%)", "0", "39", "", - "50 (37.9%)", "0", "38", "", "0", "0", "", "0", "0", "", "0", - "0", "", "43 (32.6%)", "33", "C: Combination", "Grade 5 (%)", - "(N=132)", "", "0", "0", "0", "", "0", "0", "0", "", "51 (38.6%)", - "39", "0", "", "0", "0", "", "43 (32.6%)", "33", "", "0", "0", - "", "0", "0" - ), - .Dim = c(27L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 1 is produced correctly", { @@ -114,39 +75,13 @@ testthat::test_that("AET04_PI variant 1 is produced correctly", { decreasing = TRUE ) at_least_10percent_any <- has_fraction_in_any_col(atleast = 0.1, col_indices = c(1, 4, 7)) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_10percent_any)) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "dcd A.1.1.1.1", "dcd A.1.1.1.2", - "cl B.2", "dcd B.2.2.3.1", "dcd B.2.1.2.1", "cl D.1", "dcd D.1.1.1.1", - "dcd D.1.1.4.2", "cl D.2", "dcd D.2.1.5.3", "cl B.1", "dcd B.1.1.1.1", - "cl C.2", "dcd C.2.1.2.1", "cl C.1", "dcd C.1.1.1.3", "A: Drug X", - "Any Grade (%)", "(N=134)", "", "37", "36", "", "36", "37", "", - "37", "36", "", "35", "", "35", "", "26", "", "32", "A: Drug X", - "Grade 3-4 (%)", "(N=134)", "", "0", "0", "", "0", "37", "", - "0", "36", "", "0", "", "0", "", "0", "", "32", "A: Drug X", - "Grade 5 (%)", "(N=134)", "", "0", "0", "", "0", "0", "", "37", - "0", "", "0", "", "35", "", "0", "", "0", "B: Placebo", "Any Grade (%)", - "(N=134)", "", "34", "36", "", "40", "33", "", "31", "31", "", - "43", "", "37", "", "36", "", "34", "B: Placebo", "Grade 3-4 (%)", - "(N=134)", "", "0", "0", "", "0", "33", "", "0", "31", "", "0", - "", "0", "", "0", "", "34", "B: Placebo", "Grade 5 (%)", "(N=134)", - "", "0", "0", "", "0", "0", "", "31", "0", "", "0", "", "37", - "", "0", "", "0", "C: Combination", "Any Grade (%)", "(N=132)", - "", "48", "38", "", "39", "39", "", "39", "38", "", "43", "", - "33", "", "42", "", "33", "C: Combination", "Grade 3-4 (%)", - "(N=132)", "", "0", "0", "", "0", "39", "", "0", "38", "", "0", - "", "0", "", "0", "", "33", "C: Combination", "Grade 5 (%)", - "(N=132)", "", "0", "0", "", "0", "0", "", "39", "0", "", "0", - "", "33", "", "0", "", "0" - ), - .Dim = c(20L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 2 is produced correctly", { @@ -163,27 +98,13 @@ testthat::test_that("AET04_PI variant 2 is produced correctly", { ) at_least_37percent_any_drugx <- has_fraction_in_cols(atleast = 0.37, col_indices = 1) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_37percent_any_drugx)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "dcd A.1.1.1.1", "cl D.1", - "dcd D.1.1.1.1", "A: Drug X", "Any Grade (%)", "(N=134)", "", - "37", "", "37", "A: Drug X", "Grade 3-4 (%)", "(N=134)", "", - "0", "", "0", "A: Drug X", "Grade 5 (%)", "(N=134)", "", "0", - "", "37", "B: Placebo", "Any Grade (%)", "(N=134)", "", "34", - "", "31", "B: Placebo", "Grade 3-4 (%)", "(N=134)", "", "0", - "", "0", "B: Placebo", "Grade 5 (%)", "(N=134)", "", "0", "", - "31", "C: Combination", "Any Grade (%)", "(N=132)", "", "48", - "", "39", "C: Combination", "Grade 3-4 (%)", "(N=132)", "", "0", - "", "0", "C: Combination", "Grade 5 (%)", "(N=132)", "", "0", - "", "39" - ), - .Dim = c(7L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 3 is produced correctly", { @@ -200,31 +121,13 @@ testthat::test_that("AET04_PI variant 3 is produced correctly", { ) at_least_40percent_any <- has_fraction_in_any_col(atleast = 0.40, col_indices = c(1, 4, 7)) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_40percent_any)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "dcd A.1.1.1.1", "cl B.2", - "dcd B.2.2.3.1", "cl D.2", "dcd D.2.1.5.3", "cl C.2", "dcd C.2.1.2.1", - "A: Drug X", "Any Grade (%)", "(N=134)", "", "37", "", "36", - "", "35", "", "26", "A: Drug X", "Grade 3-4 (%)", "(N=134)", - "", "0", "", "0", "", "0", "", "0", "A: Drug X", "Grade 5 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "B: Placebo", - "Any Grade (%)", "(N=134)", "", "34", "", "40", "", "43", "", - "36", "B: Placebo", "Grade 3-4 (%)", "(N=134)", "", "0", "", - "0", "", "0", "", "0", "B: Placebo", "Grade 5 (%)", "(N=134)", - "", "0", "", "0", "", "0", "", "0", "C: Combination", "Any Grade (%)", - "(N=132)", "", "48", "", "39", "", "43", "", "42", "C: Combination", - "Grade 3-4 (%)", "(N=132)", "", "0", "", "0", "", "0", "", "0", - "C: Combination", "Grade 5 (%)", "(N=132)", "", "0", "", "0", - "", "0", "", "0" - ), - .Dim = 11:10 - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 4 is produced correctly", { @@ -242,25 +145,13 @@ testthat::test_that("AET04_PI variant 4 is produced correctly", { at_least_30percent_any <- has_fraction_in_any_col(atleast = 0.3, col_indices = c(1, 4, 7)) at_least_15percent_diff <- has_fractions_difference(atleast = 0.15, col_indices = c(1, 4, 7)) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_30percent_any & at_least_15percent_diff)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl C.2", "dcd C.2.1.2.1", "A: Drug X", - "Any Grade (%)", "(N=134)", "", "26", "A: Drug X", "Grade 3-4 (%)", - "(N=134)", "", "0", "A: Drug X", "Grade 5 (%)", "(N=134)", "", - "0", "B: Placebo", "Any Grade (%)", "(N=134)", "", "36", "B: Placebo", - "Grade 3-4 (%)", "(N=134)", "", "0", "B: Placebo", "Grade 5 (%)", - "(N=134)", "", "0", "C: Combination", "Any Grade (%)", "(N=132)", - "", "42", "C: Combination", "Grade 3-4 (%)", "(N=132)", "", "0", - "C: Combination", "Grade 5 (%)", "(N=132)", "", "0" - ), - .Dim = c(5L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 5 is produced correctly", { @@ -278,34 +169,13 @@ testthat::test_that("AET04_PI variant 5 is produced correctly", { at_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 4, 7)) at_least_20percent_g5 <- has_fraction_in_any_col(atleast = 0.20, col_indices = c(3, 6, 9)) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_40percent_any | at_least_20percent_g5)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "dcd A.1.1.1.1", "cl B.2", - "dcd B.2.2.3.1", "cl D.1", "dcd D.1.1.1.1", "cl D.2", "dcd D.2.1.5.3", - "cl B.1", "dcd B.1.1.1.1", "cl C.2", "dcd C.2.1.2.1", "A: Drug X", - "Any Grade (%)", "(N=134)", "", "37", "", "36", "", "37", "", - "35", "", "35", "", "26", "A: Drug X", "Grade 3-4 (%)", "(N=134)", - "", "0", "", "0", "", "0", "", "0", "", "0", "", "0", "A: Drug X", - "Grade 5 (%)", "(N=134)", "", "0", "", "0", "", "37", "", "0", - "", "35", "", "0", "B: Placebo", "Any Grade (%)", "(N=134)", - "", "34", "", "40", "", "31", "", "43", "", "37", "", "36", "B: Placebo", - "Grade 3-4 (%)", "(N=134)", "", "0", "", "0", "", "0", "", "0", - "", "0", "", "0", "B: Placebo", "Grade 5 (%)", "(N=134)", "", - "0", "", "0", "", "31", "", "0", "", "37", "", "0", "C: Combination", - "Any Grade (%)", "(N=132)", "", "48", "", "39", "", "39", "", - "43", "", "33", "", "42", "C: Combination", "Grade 3-4 (%)", - "(N=132)", "", "0", "", "0", "", "0", "", "0", "", "0", "", "0", - "C: Combination", "Grade 5 (%)", "(N=132)", "", "0", "", "0", - "", "39", "", "0", "", "33", "", "0" - ), - .Dim = c(15L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 6 is produced correctly", { @@ -350,34 +220,13 @@ testthat::test_that("AET04_PI variant 6 is produced correctly", { ) at_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 5, 9)) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_40percent_any)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "dcd A.1.1.1.1", "cl B.2", - "dcd B.2.2.3.1", "cl D.2", "dcd D.2.1.5.3", "cl C.2", "dcd C.2.1.2.1", - "A: Drug X", "Any Grade (%)", "(N=134)", "", "37", "", "36", - "", "35", "", "26", "A: Drug X", "Grade 1-2 (%)", "(N=134)", - "", "37", "", "36", "", "35", "", "26", "A: Drug X", "Grade 3-4 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "A: Drug X", "Grade 5 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "B: Placebo", - "Any Grade (%)", "(N=134)", "", "34", "", "40", "", "43", "", - "36", "B: Placebo", "Grade 1-2 (%)", "(N=134)", "", "34", "", - "40", "", "43", "", "36", "B: Placebo", "Grade 3-4 (%)", "(N=134)", - "", "0", "", "0", "", "0", "", "0", "B: Placebo", "Grade 5 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "C: Combination", - "Any Grade (%)", "(N=132)", "", "48", "", "39", "", "43", "", - "42", "C: Combination", "Grade 1-2 (%)", "(N=132)", "", "48", - "", "39", "", "43", "", "42", "C: Combination", "Grade 3-4 (%)", - "(N=132)", "", "0", "", "0", "", "0", "", "0", "C: Combination", - "Grade 5 (%)", "(N=132)", "", "0", "", "0", "", "0", "", "0" - ), - .Dim = c(11L, 13L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 7 is produced correctly", { @@ -422,34 +271,13 @@ testthat::test_that("AET04_PI variant 7 is produced correctly", { ) at_least_40percent_any <- has_fraction_in_any_col(atleast = 0.4, col_indices = c(1, 5, 9)) + result <- full_table %>% trim_rows(criteria = criteria_fun) %>% prune_table(keep_rows(at_least_40percent_any)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "cl A.1", "dcd A.1.1.1.1", "cl B.2", - "dcd B.2.2.3.1", "cl D.2", "dcd D.2.1.5.3", "cl C.2", "dcd C.2.1.2.1", - "A: Drug X", "Any Grade (%)", "(N=134)", "", "37", "", "36", - "", "35", "", "26", "A: Drug X", "Grade 3-4 (%)", "(N=134)", - "", "0", "", "0", "", "0", "", "0", "A: Drug X", "Grade 3-5 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "A: Drug X", "Grade 5 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "B: Placebo", - "Any Grade (%)", "(N=134)", "", "34", "", "40", "", "43", "", - "36", "B: Placebo", "Grade 3-4 (%)", "(N=134)", "", "0", "", - "0", "", "0", "", "0", "B: Placebo", "Grade 3-5 (%)", "(N=134)", - "", "0", "", "0", "", "0", "", "0", "B: Placebo", "Grade 5 (%)", - "(N=134)", "", "0", "", "0", "", "0", "", "0", "C: Combination", - "Any Grade (%)", "(N=132)", "", "48", "", "39", "", "43", "", - "42", "C: Combination", "Grade 3-4 (%)", "(N=132)", "", "0", - "", "0", "", "0", "", "0", "C: Combination", "Grade 3-5 (%)", - "(N=132)", "", "0", "", "0", "", "0", "", "0", "C: Combination", - "Grade 5 (%)", "(N=132)", "", "0", "", "0", "", "0", "", "0" - ), - .Dim = c(11L, 13L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET04_PI variant 8 is produced correctly", { @@ -473,6 +301,7 @@ testthat::test_that("AET04_PI variant 8 is produced correctly", { build_table(adae_max, col_counts = col_counts) at_least_20percent_any <- has_fraction_in_any_col(atleast = 0.2, col_indices = c(1, 4, 7)) + result <- full_table %>% prune_table(keep_rows(at_least_20percent_any)) %>% sort_at_path( @@ -480,28 +309,7 @@ testthat::test_that("AET04_PI variant 8 is produced correctly", { scorefun = score_occurrences_cols(col_indices = c(1, 4, 7)), decreasing = TRUE ) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "dcd D.2.1.5.3", "dcd A.1.1.1.1", "dcd B.2.2.3.1", - "dcd A.1.1.1.2", "dcd B.2.1.2.1", "dcd D.1.1.1.1", "dcd D.1.1.4.2", - "dcd B.1.1.1.1", "dcd C.2.1.2.1", "dcd C.1.1.1.3", "A: Drug X", - "Any Grade (%)", "(N=134)", "35", "37", "36", "36", "37", "37", - "36", "35", "26", "32", "A: Drug X", "Grade 3-4 (%)", "(N=134)", - "0", "0", "0", "0", "37", "0", "36", "0", "0", "32", "A: Drug X", - "Grade 5 (%)", "(N=134)", "0", "0", "0", "0", "0", "37", "0", - "35", "0", "0", "B: Placebo", "Any Grade (%)", "(N=134)", "43", - "34", "40", "36", "33", "31", "31", "37", "36", "34", "B: Placebo", - "Grade 3-4 (%)", "(N=134)", "0", "0", "0", "0", "33", "0", "31", - "0", "0", "34", "B: Placebo", "Grade 5 (%)", "(N=134)", "0", - "0", "0", "0", "0", "31", "0", "37", "0", "0", "C: Combination", - "Any Grade (%)", "(N=132)", "43", "48", "39", "38", "39", "39", - "38", "33", "42", "33", "C: Combination", "Grade 3-4 (%)", "(N=132)", - "0", "0", "0", "0", "39", "0", "38", "0", "0", "33", "C: Combination", - "Grade 5 (%)", "(N=132)", "0", "0", "0", "0", "0", "39", "0", - "33", "0", "0" - ), - .Dim = c(13L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet05.R b/tests/testthat/test-table_aet05.R index d8c7441eaa..e9157b06fa 100644 --- a/tests/testthat/test-table_aet05.R +++ b/tests/testthat/test-table_aet05.R @@ -7,6 +7,7 @@ testthat::test_that("AET05 variant 1 is produced correctly", { dplyr::filter(PARAM == "Time to first occurrence of any adverse event") %>% dplyr::mutate(is_event = CNSR == 0) %>% dplyr::mutate(n_events = as.integer(is_event)) + result <- basic_table() %>% split_cols_by("ARM") %>% add_colcounts() %>% @@ -16,21 +17,9 @@ testthat::test_that("AET05 variant 1 is produced correctly", { control = control_incidence_rate(time_unit_output = 100) ) %>% build_table(anl, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total patient-years at risk", - "Number of adverse events observed", "AE rate per 100 patient-years", - "95% CI", "A: Drug X", "(N=134)", "162.4", "78", "48.03", - "(37.37, 58.69)", "B: Placebo", "(N=134)", "103.8", "104", "100.15", - "(80.90, 119.40)", "C: Combination", "(N=132)", "172.6", "67", "38.82", - "(29.53, 48.12)" - ), - .Dim = c(6L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET05 variant 2 is produced correctly", { @@ -38,6 +27,7 @@ testthat::test_that("AET05 variant 2 is produced correctly", { dplyr::filter(PARAM == "Time to first occurrence of any adverse event") %>% dplyr::mutate(is_event = CNSR == 0) %>% dplyr::mutate(n_events = as.integer(is_event)) + result <- basic_table() %>% split_cols_by("ARM") %>% add_colcounts() %>% @@ -47,19 +37,7 @@ testthat::test_that("AET05 variant 2 is produced correctly", { control = control_incidence_rate(conf_type = "exact", time_unit_output = 100) ) %>% build_table(anl, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total patient-years at risk", - "Number of adverse events observed", "AE rate per 100 patient-years", - "95% CI", "A: Drug X", "(N=134)", "162.4", "78", "48.03", - "(37.97, 59.94)", "B: Placebo", "(N=134)", "103.8", "104", "100.15", - "(81.83, 121.35)", "C: Combination", "(N=132)", "172.6", "67", "38.82", - "(30.09, 49.30)" - ), - .Dim = c(6L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet06.R b/tests/testthat/test-table_aet06.R index e6a560972f..ce223709ff 100644 --- a/tests/testthat/test-table_aet06.R +++ b/tests/testthat/test-table_aet06.R @@ -74,61 +74,11 @@ testthat::test_that("AET06 variant 1 is produced correctly", { ) ) %>% count_occurrences(vars = "AEDECOD") - result <- build_table(lyt, adae, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "Total number of patients with at least one adverse event", - "Overall total number of events", "cl A.1", - "Total number of patients with at least one adverse event", - "Total number of events", "dcd A.1.1.1.1", "dcd A.1.1.1.2", "cl B.1", - "Total number of patients with at least one adverse event", "Total number of events", - "dcd B.1.1.1.1", "cl B.2", "Total number of patients with at least one adverse event", - "Total number of events", "dcd B.2.1.2.1", "dcd B.2.2.3.1", "cl C.1", - "Total number of patients with at least one adverse event", "Total number of events", - "dcd C.1.1.1.3", "cl C.2", "Total number of patients with at least one adverse event", - "Total number of events", "dcd C.2.1.2.1", "cl D.1", - "Total number of patients with at least one adverse event", - "Total number of events", "dcd D.1.1.1.1", "dcd D.1.1.4.2", "cl D.2", - "Total number of patients with at least one adverse event", "Total number of events", - "dcd D.2.1.5.3", "A: Drug X", "F", "(N=79)", "72 (91.1%)", "377", - "", "53 (67.1%)", "85", "34 (43.0%)", "32 (40.5%)", "", "28 (35.4%)", - "33", "28 (35.4%)", "", "46 (58.2%)", "81", "29 (36.7%)", "30 (38.0%)", - "", "30 (38.0%)", "39", "30 (38.0%)", "", "23 (29.1%)", "32", "23 (29.1%)", - "", "45 (57.0%)", "72", "25 (31.6%)", "30 (38.0%)", "", "26 (32.9%)", - "35", "26 (32.9%)", "A: Drug X", "M", "(N=55)", "50 (90.9%)", - "232", "", "25 (45.5%)", "47", "16 (29.1%)", "16 (29.1%)", "", - "19 (34.5%)", "23", "19 (34.5%)", "", "33 (60.0%)", "48", "20 (36.4%)", - "18 (32.7%)", "", "13 (23.6%)", "16", "13 (23.6%)", "", "12 (21.8%)", - "16", "12 (21.8%)", "", "34 (61.8%)", "55", "25 (45.5%)", "18 (32.7%)", - "", "21 (38.2%)", "27", "21 (38.2%)", "B: Placebo", "F", "(N=82)", - "77 (93.9%)", "419", "", "51 (62.2%)", "93", "31 (37.8%)", "33 (40.2%)", - "", "33 (40.2%)", "36", "33 (40.2%)", "", "45 (54.9%)", "86", - "30 (36.6%)", "32 (39.0%)", "", "36 (43.9%)", "52", "36 (43.9%)", - "", "36 (43.9%)", "39", "36 (43.9%)", "", "40 (48.8%)", "64", - "29 (35.4%)", "22 (26.8%)", "", "40 (48.8%)", "49", "40 (48.8%)", - "B: Placebo", "M", "(N=52)", "46 (88.5%)", "203", "", "24 (46.2%)", - "37", "14 (26.9%)", "15 (28.8%)", "", "16 (30.8%)", "24", "16 (30.8%)", - "", "29 (55.8%)", "52", "14 (26.9%)", "22 (42.3%)", "", "10 (19.2%)", - "11", "10 (19.2%)", "", "12 (23.1%)", "14", "12 (23.1%)", "", - "27 (51.9%)", "42", "13 (25.0%)", "20 (38.5%)", "", "18 (34.6%)", - "23", "18 (34.6%)", "C: Combination", "F", "(N=70)", "65 (92.9%)", - "378", "", "43 (61.4%)", "86", "33 (47.1%)", "24 (34.3%)", "", - "24 (34.3%)", "35", "24 (34.3%)", "", "44 (62.9%)", "64", "22 (31.4%)", - "26 (37.1%)", "", "27 (38.6%)", "44", "27 (38.6%)", "", "30 (42.9%)", - "33", "30 (42.9%)", "", "41 (58.6%)", "73", "27 (38.6%)", "27 (38.6%)", - "", "34 (48.6%)", "43", "34 (48.6%)", "C: Combination", "M", - "(N=62)", "55 (88.7%)", "325", "", "46 (74.2%)", "74", "30 (48.4%)", - "26 (41.9%)", "", "19 (30.6%)", "27", "19 (30.6%)", "", "41 (66.1%)", - "79", "30 (48.4%)", "25 (40.3%)", "", "16 (25.8%)", "20", "16 (25.8%)", - "", "25 (40.3%)", "32", "25 (40.3%)", "", "39 (62.9%)", "62", - "24 (38.7%)", "23 (37.1%)", "", "23 (37.1%)", "31", "23 (37.1%)" - ), - .Dim = c(36L, 7L) - ) + result <- build_table(lyt, adae, alt_counts_df = adsl) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET06 variant 3 is produced correctly", { @@ -163,7 +113,6 @@ testthat::test_that("AET06 variant 3 is produced correctly", { count_occurrences(vars = "AEDECOD", .indent_mods = -1L) %>% append_varlabels(adae, "AEDECOD", indent = 1L) - result <- build_table( lyt = lyt, df = adae, @@ -179,70 +128,9 @@ testthat::test_that("AET06 variant 3 is produced correctly", { path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- c( - "Body System or Organ Class", "A: Drug X", "A: Drug X", "A: Drug X", "A: Drug X", "B: Placebo", "B: Placebo", "B: Placebo", # nolint - "B: Placebo", "C: Combination", "C: Combination", "C: Combination", "C: Combination", - " Dictionary-Derived Term", "<18.5", "18.5 - 24.9", "25 - 29.9", ">30", "<18.5", "18.5 - 24.9", "25 - 29.9", ">30", - "<18.5", "18.5 - 24.9", "25 - 29.9", ">30", - "", "(N=44)", "(N=17)", "(N=11)", "(N=62)", "(N=37)", "(N=18)", "(N=10)", "(N=69)", "(N=28)", "(N=20)", "(N=18)", "(N=66)", # nolint - "Total number of patients with at least one adverse event", "41 (93.2%)", "14 (82.4%)", "11 (100%)", "56 (90.3%)", - "35 (94.6%)", "16 (88.9%)", "9 (90.0%)", "63 (91.3%)", "25 (89.3%)", "19 (95.0%)", "15 (83.3%)", "61 (92.4%)", - "Overall total number of events", "186", "80", "66", "277", "174", "89", "47", "312", "137", "129", "100", "337", - "cl A.1", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "23 (52.3%)", "12 (70.6%)", "7 (63.6%)", "36 (58.1%)", - "19 (51.4%)", "10 (55.6%)", "6 (60.0%)", "40 (58.0%)", "16 (57.1%)", "13 (65.0%)", "14 (77.8%)", "46 (69.7%)", - "Total number of events", "38", "22", "13", "59", "35", "22", "6", "67", "30", "23", "30", "77", - "dcd A.1.1.1.1", "14 (31.8%)", "7 (41.2%)", "3 (27.3%)", "26 (41.9%)", "12 (32.4%)", "6 (33.3%)", "4 (40.0%)", "23 (33.3%)", # nolint - "12 (42.9%)", "7 (35.0%)", "13 (72.2%)", "31 (47.0%)", - "dcd A.1.1.1.2", "15 (34.1%)", "8 (47.1%)", "5 (45.5%)", "20 (32.3%)", "12 (32.4%)", "8 (44.4%)", "2 (20.0%)", "26 (37.7%)", # nolint - "9 (32.1%)", "7 (35.0%)", "7 (38.9%)", "27 (40.9%)", - "cl B.2", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "23 (52.3%)", "10 (58.8%)", "8 (72.7%)", "38 (61.3%)", - "21 (56.8%)", "8 (44.4%)", "7 (70.0%)", "38 (55.1%)", "16 (57.1%)", "16 (80.0%)", "12 (66.7%)", "41 (62.1%)", - "Total number of events", "37", "19", "12", "61", "41", "18", "12", "67", "28", "28", "18", "69", - "dcd B.2.2.3.1", "13 (29.5%)", "7 (41.2%)", "6 (54.5%)", "22 (35.5%)", "14 (37.8%)", "7 (38.9%)", "6 (60.0%)", "27 (39.1%)", # nolint - "7 (25.0%)", "13 (65.0%)", "5 (27.8%)", "26 (39.4%)", - "dcd B.2.1.2.1", "14 (31.8%)", "8 (47.1%)", "4 (36.4%)", "23 (37.1%)", "14 (37.8%)", "6 (33.3%)", "4 (40.0%)", "20 (29.0%)", # nolint - "13 (46.4%)", "8 (40.0%)", "8 (44.4%)", "23 (34.8%)", - "cl D.1", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "24 (54.5%)", "9 (52.9%)", "8 (72.7%)", "38 (61.3%)", - "18 (48.6%)", "5 (27.8%)", "7 (70.0%)", "37 (53.6%)", "15 (53.6%)", "12 (60.0%)", "11 (61.1%)", "42 (63.6%)", - "Total number of events", "38", "11", "17", "61", "30", "11", "14", "51", "30", "23", "16", "66", - "dcd D.1.1.1.1", "13 (29.5%)", "7 (41.2%)", "7 (63.6%)", "23 (37.1%)", "13 (35.1%)", "3 (16.7%)", "4 (40.0%)", "22 (31.9%)", # nolint - "12 (42.9%)", "6 (30.0%)", "8 (44.4%)", "25 (37.9%)", - "dcd D.1.1.4.2", "16 (36.4%)", "4 (23.5%)", "6 (54.5%)", "22 (35.5%)", "10 (27.0%)", "4 (22.2%)", "5 (50.0%)", "23 (33.3%)", # nolint - "10 (35.7%)", "9 (45.0%)", "6 (33.3%)", "25 (37.9%)", - "cl D.2", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "14 (31.8%)", "7 (41.2%)", "5 (45.5%)", "21 (33.9%)", - "14 (37.8%)", "10 (55.6%)", "4 (40.0%)", "30 (43.5%)", "13 (46.4%)", "10 (50.0%)", "7 (38.9%)", "27 (40.9%)", - "Total number of events", "20", "7", "10", "25", "17", "14", "5", "36", "18", "15", "10", "31", - "dcd D.2.1.5.3", "14 (31.8%)", "7 (41.2%)", "5 (45.5%)", "21 (33.9%)", "14 (37.8%)", "10 (55.6%)", "4 (40.0%)", "30 (43.5%)", # nolint - "13 (46.4%)", "10 (50.0%)", "7 (38.9%)", "27 (40.9%)", - "cl B.1", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "17 (38.6%)", "5 (29.4%)", "7 (63.6%)", "18 (29.0%)", - "14 (37.8%)", "8 (44.4%)", "4 (40.0%)", "23 (33.3%)", "7 (25.0%)", "10 (50.0%)", "7 (38.9%)", "19 (28.8%)", - "Total number of events", "22", "5", "7", "22", "16", "11", "4", "29", "11", "12", "8", "31", - "dcd B.1.1.1.1", "17 (38.6%)", "5 (29.4%)", "7 (63.6%)", "18 (29.0%)", "14 (37.8%)", "8 (44.4%)", "4 (40.0%)", "23 (33.3%)", # nolint - "7 (25.0%)", "10 (50.0%)", "7 (38.9%)", "19 (28.8%)", - "cl C.2", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "14 (31.8%)", "4 (23.5%)", "2 (18.2%)", "15 (24.2%)", - "15 (40.5%)", "5 (27.8%)", "4 (40.0%)", "24 (34.8%)", "10 (35.7%)", "13 (65.0%)", "8 (44.4%)", "24 (36.4%)", - "Total number of events", "17", "9", "3", "19", "15", "6", "5", "27", "12", "16", "9", "28", - "dcd C.2.1.2.1", "14 (31.8%)", "4 (23.5%)", "2 (18.2%)", "15 (24.2%)", "15 (40.5%)", "5 (27.8%)", "4 (40.0%)", "24 (34.8%)", # nolint - "10 (35.7%)", "13 (65.0%)", "8 (44.4%)", "24 (36.4%)", - "cl C.1", "", "", "", "", "", "", "", "", "", "", "", "", - "Total number of patients with at least one adverse event", "11 (25.0%)", "4 (23.5%)", "4 (36.4%)", "24 (38.7%)", - "13 (35.1%)", "6 (33.3%)", "1 (10.0%)", "26 (37.7%)", "6 (21.4%)", "7 (35.0%)", "6 (33.3%)", "24 (36.4%)", - "Total number of events", "14", "7", "4", "30", "20", "7", "1", "35", "8", "12", "9", "35", - "dcd C.1.1.1.3", "11 (25.0%)", "4 (23.5%)", "4 (36.4%)", "24 (38.7%)", "13 (35.1%)", "6 (33.3%)", "1 (10.0%)", "26 (37.7%)", # nolint - "6 (21.4%)", "7 (35.0%)", "6 (33.3%)", "24 (36.4%)" - ) - - expected_matrix <- matrix(expected_matrix, nrow = 36, ncol = 13, byrow = TRUE) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET06 variant 5 is produced correctly", { @@ -282,88 +170,9 @@ testthat::test_that("AET06 variant 5 is produced correctly", { ) ) %>% count_occurrences("AEDECOD") - result <- build_table(lyt, adae, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "Total number of patients with at least one adverse event", - "Overall total number of events", "cl A.1", "Total number of patients with at least one adverse event", - "Total number of events", "hlt A.1.1.1", "Total number of patients with at least one adverse event", - "Total number of events", "dcd A.1.1.1.1", "dcd A.1.1.1.2", "cl B.1", - "Total number of patients with at least one adverse event", "Total number of events", - "hlt B.1.1.1", "Total number of patients with at least one adverse event", - "Total number of events", "dcd B.1.1.1.1", "cl B.2", "Total number of patients with at least one adverse event", - "Total number of events", "hlt B.2.1.2", "Total number of patients with at least one adverse event", - "Total number of events", "dcd B.2.1.2.1", "hlt B.2.2.3", - "Total number of patients with at least one adverse event", - "Total number of events", "dcd B.2.2.3.1", "cl C.1", "Total number of patients with at least one adverse event", - "Total number of events", "hlt C.1.1.1", "Total number of patients with at least one adverse event", - "Total number of events", "dcd C.1.1.1.3", "cl C.2", "Total number of patients with at least one adverse event", - "Total number of events", "hlt C.2.1.2", "Total number of patients with at least one adverse event", - "Total number of events", "dcd C.2.1.2.1", "cl D.1", "Total number of patients with at least one adverse event", - "Total number of events", "hlt D.1.1.1", "Total number of patients with at least one adverse event", - "Total number of events", "dcd D.1.1.1.1", "hlt D.1.1.4", - "Total number of patients with at least one adverse event", - "Total number of events", "dcd D.1.1.4.2", "cl D.2", "Total number of patients with at least one adverse event", - "Total number of events", "hlt D.2.1.5", "Total number of patients with at least one adverse event", - "Total number of events", "dcd D.2.1.5.3", "A: Drug X", "F", - "(N=79)", "72 (91.1%)", "377", "", "53 (67.1%)", "85", "", "53 (67.1%)", - "85", "34 (43.0%)", "32 (40.5%)", "", "28 (35.4%)", "33", "", "28 (35.4%)", - "33", "28 (35.4%)", "", "46 (58.2%)", "81", "", "29 (36.7%)", - "41", "29 (36.7%)", "", "30 (38.0%)", "40", "30 (38.0%)", "", "30 (38.0%)", - "39", "", "30 (38.0%)", "39", "30 (38.0%)", "", "23 (29.1%)", "32", - "", "23 (29.1%)", "32", "23 (29.1%)", "", "45 (57.0%)", "72", "", - "25 (31.6%)", "32", "25 (31.6%)", "", "30 (38.0%)", "40", "30 (38.0%)", - "", "26 (32.9%)", "35", "", "26 (32.9%)", "35", "26 (32.9%)", - "A: Drug X", "M", "(N=55)", "50 (90.9%)", "232", "", "25 (45.5%)", - "47", "", "25 (45.5%)", "47", "16 (29.1%)", "16 (29.1%)", "", - "19 (34.5%)", "23", "", "19 (34.5%)", "23", "19 (34.5%)", "", - "33 (60.0%)", "48", "", "20 (36.4%)", "24", "20 (36.4%)", "", "18 (32.7%)", - "24", "18 (32.7%)", "", "13 (23.6%)", "16", "", "13 (23.6%)", - "16", "13 (23.6%)", "", "12 (21.8%)", "16", "", "12 (21.8%)", - "16", "12 (21.8%)", "", "34 (61.8%)", "55", "", "25 (45.5%)", - "29", "25 (45.5%)", "", "18 (32.7%)", "26", "18 (32.7%)", "", - "21 (38.2%)", "27", "", "21 (38.2%)", "27", "21 (38.2%)", "B: Placebo", - "F", "(N=82)", "77 (93.9%)", "419", "", "51 (62.2%)", "93", "", - "51 (62.2%)", "93", "31 (37.8%)", "33 (40.2%)", "", "33 (40.2%)", - "36", "", "33 (40.2%)", "36", "33 (40.2%)", "", "45 (54.9%)", - "86", "", "30 (36.6%)", "43", "30 (36.6%)", "", "32 (39.0%)", "43", - "32 (39.0%)", "", "36 (43.9%)", "52", "", "36 (43.9%)", "52", "36 (43.9%)", - "", "36 (43.9%)", "39", "", "36 (43.9%)", "39", "36 (43.9%)", - "", "40 (48.8%)", "64", "", "29 (35.4%)", "36", "29 (35.4%)", - "", "22 (26.8%)", "28", "22 (26.8%)", "", "40 (48.8%)", "49", - "", "40 (48.8%)", "49", "40 (48.8%)", "B: Placebo", "M", "(N=52)", - "46 (88.5%)", "203", "", "24 (46.2%)", "37", "", "24 (46.2%)", - "37", "14 (26.9%)", "15 (28.8%)", "", "16 (30.8%)", "24", "", - "16 (30.8%)", "24", "16 (30.8%)", "", "29 (55.8%)", "52", "", - "14 (26.9%)", "19", "14 (26.9%)", "", "22 (42.3%)", "33", "22 (42.3%)", - "", "10 (19.2%)", "11", "", "10 (19.2%)", "11", "10 (19.2%)", - "", "12 (23.1%)", "14", "", "12 (23.1%)", "14", "12 (23.1%)", - "", "27 (51.9%)", "42", "", "13 (25.0%)", "15", "13 (25.0%)", "", - "20 (38.5%)", "27", "20 (38.5%)", "", "18 (34.6%)", "23", "", - "18 (34.6%)", "23", "18 (34.6%)", "C: Combination", "F", "(N=70)", - "65 (92.9%)", "378", "", "43 (61.4%)", "86", "", "43 (61.4%)", - "86", "33 (47.1%)", "24 (34.3%)", "", "24 (34.3%)", "35", "", - "24 (34.3%)", "35", "24 (34.3%)", "", "44 (62.9%)", "64", "", - "22 (31.4%)", "27", "22 (31.4%)", "", "26 (37.1%)", "37", "26 (37.1%)", - "", "27 (38.6%)", "44", "", "27 (38.6%)", "44", "27 (38.6%)", - "", "30 (42.9%)", "33", "", "30 (42.9%)", "33", "30 (42.9%)", - "", "41 (58.6%)", "73", "", "27 (38.6%)", "39", "27 (38.6%)", - "", "27 (38.6%)", "34", "27 (38.6%)", "", "34 (48.6%)", "43", - "", "34 (48.6%)", "43", "34 (48.6%)", "C: Combination", "M", - "(N=62)", "55 (88.7%)", "325", "", "46 (74.2%)", "74", "", "46 (74.2%)", - "74", "30 (48.4%)", "26 (41.9%)", "", "19 (30.6%)", "27", "", - "19 (30.6%)", "27", "19 (30.6%)", "", "41 (66.1%)", "79", "", - "30 (48.4%)", "39", "30 (48.4%)", "", "25 (40.3%)", "40", "25 (40.3%)", - "", "16 (25.8%)", "20", "", "16 (25.8%)", "20", "16 (25.8%)", - "", "25 (40.3%)", "32", "", "25 (40.3%)", "32", "25 (40.3%)", - "", "39 (62.9%)", "62", "", "24 (38.7%)", "32", "24 (38.7%)", - "", "23 (37.1%)", "30", "23 (37.1%)", "", "23 (37.1%)", "31", - "", "23 (37.1%)", "31", "23 (37.1%)" - ), - .Dim = c(63L, 7L) - ) + result <- build_table(lyt, adae, alt_counts_df = adsl) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet06_smq.R b/tests/testthat/test-table_aet06_smq.R index dfa7d4d382..4c90d41bfb 100644 --- a/tests/testthat/test-table_aet06_smq.R +++ b/tests/testthat/test-table_aet06_smq.R @@ -69,52 +69,8 @@ testthat::test_that("AET06_SMQ variant 1 is produced correctly", { result <- build_table(lyt, adae_f, alt_counts_df = adsl) %>% sort_at_path(path = c("SMQ", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "", "Total number of patients with at least one adverse event", - "SMQ 1 (broad)", "Total number of patients with at least one adverse event", - "Total number of events", "dcd A.1.1.1.1", "dcd A.1.1.1.2", "dcd D.1.1.1.1", - "dcd D.1.1.4.2", "dcd B.1.1.1.1", "dcd C.1.1.1.3", "SMQ 1 (narrow)", - "Total number of patients with at least one adverse event", "Total number of events", - "dcd A.1.1.1.1", "dcd A.1.1.1.2", "dcd D.1.1.1.1", "dcd D.1.1.4.2", - "AESI", "Total number of patients with at least one adverse event", - "Total number of events", "dcd B.2.2.3.1", "dcd A.1.1.1.2", "dcd B.2.1.2.1", - "dcd C.2.1.2.1", "A: Drug X", "F", "(N=79)", "72 (91.1%)", "", - "69 (87.3%)", "229", "34 (43.0%)", "32 (40.5%)", "25 (31.6%)", - "30 (38.0%)", "28 (35.4%)", "30 (38.0%)", "", "64 (81.0%)", "157", - "34 (43.0%)", "32 (40.5%)", "25 (31.6%)", "30 (38.0%)", "", "59 (74.7%)", - "155", "30 (38.0%)", "32 (40.5%)", "29 (36.7%)", "23 (29.1%)", - "A: Drug X", "M", "(N=55)", "50 (90.9%)", "", "46 (83.6%)", "141", - "16 (29.1%)", "16 (29.1%)", "25 (45.5%)", "18 (32.7%)", "19 (34.5%)", - "13 (23.6%)", "", "36 (65.5%)", "102", "16 (29.1%)", "16 (29.1%)", - "25 (45.5%)", "18 (32.7%)", "", "38 (69.1%)", "90", "18 (32.7%)", - "16 (29.1%)", "20 (36.4%)", "12 (21.8%)", "B: Placebo", "F", - "(N=82)", "74 (90.2%)", "", "70 (85.4%)", "245", "31 (37.8%)", - "33 (40.2%)", "29 (35.4%)", "22 (26.8%)", "33 (40.2%)", "36 (43.9%)", - "", "63 (76.8%)", "157", "31 (37.8%)", "33 (40.2%)", "29 (35.4%)", - "22 (26.8%)", "", "66 (80.5%)", "176", "32 (39.0%)", "33 (40.2%)", - "30 (36.6%)", "36 (43.9%)", "B: Placebo", "M", "(N=52)", "45 (86.5%)", - "", "42 (80.8%)", "114", "14 (26.9%)", "15 (28.8%)", "13 (25.0%)", - "20 (38.5%)", "16 (30.8%)", "10 (19.2%)", "", "36 (69.2%)", "79", - "14 (26.9%)", "15 (28.8%)", "13 (25.0%)", "20 (38.5%)", "", "37 (71.2%)", - "83", "22 (42.3%)", "15 (28.8%)", "14 (26.9%)", "12 (23.1%)", - "C: Combination", "F", "(N=70)", "63 (90.0%)", "", "62 (88.6%)", - "238", "33 (47.1%)", "24 (34.3%)", "27 (38.6%)", "27 (38.6%)", - "24 (34.3%)", "27 (38.6%)", "", "53 (75.7%)", "159", "33 (47.1%)", - "24 (34.3%)", "27 (38.6%)", "27 (38.6%)", "", "54 (77.1%)", "138", - "26 (37.1%)", "24 (34.3%)", "22 (31.4%)", "30 (42.9%)", "C: Combination", - "M", "(N=62)", "55 (88.7%)", "", "54 (87.1%)", "183", "30 (48.4%)", - "26 (41.9%)", "24 (38.7%)", "23 (37.1%)", "19 (30.6%)", "16 (25.8%)", - "", "54 (87.1%)", "136", "30 (48.4%)", "26 (41.9%)", "24 (38.7%)", - "23 (37.1%)", "", "53 (85.5%)", "142", "25 (40.3%)", "26 (41.9%)", - "30 (48.4%)", "25 (40.3%)" - ), - .Dim = c(27L, 7L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET06_SMQ variant 2 is produced correctly", { @@ -200,45 +156,6 @@ testthat::test_that("AET06_SMQ variant 2 is produced correctly", { result <- build_table(lyt, adae_f, alt_counts_df = adsl) %>% sort_at_path(path = c("SMQ", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "", "Total number of patients with at least one adverse event", - "SMQ 1 (broad)", "Total number of patients with at least one adverse event", - "Total number of events", "dcd A.1.1.1.1", "dcd A.1.1.1.2", "dcd D.1.1.1.1", - "dcd D.1.1.4.2", "dcd B.1.1.1.1", "dcd C.1.1.1.3", "SMQ 1 (narrow)", - "Total number of patients with at least one adverse event", "Total number of events", - "dcd A.1.1.1.1", "dcd A.1.1.1.2", "dcd D.1.1.1.1", "dcd D.1.1.4.2", - "AESI", "Total number of patients with at least one adverse event", - "Total number of events", "dcd B.2.2.3.1", "dcd A.1.1.1.2", "dcd B.2.1.2.1", - "dcd C.2.1.2.1", "A: Drug X", ">= 65", "(N=0)", "0", "", "0", - "0", "0", "0", "0", "0", "0", "0", "", "0", "0", "0", - "0", "0", "0", "", "0", "0", "0", "0", "0", "0", "A: Drug X", - "< 65", "(N=134)", "122 (91.0%)", "", "115 (85.8%)", "370", "50 (37.3%)", - "48 (35.8%)", "50 (37.3%)", "48 (35.8%)", "47 (35.1%)", "43 (32.1%)", - "", "100 (74.6%)", "259", "50 (37.3%)", "48 (35.8%)", "50 (37.3%)", - "48 (35.8%)", "", "97 (72.4%)", "245", "48 (35.8%)", "48 (35.8%)", - "49 (36.6%)", "35 (26.1%)", "B: Placebo", ">= 65", "(N=0)", "0", - "", "0", "0", "0", "0", "0", "0", "0", "0", "", "0", - "0", "0", "0", "0", "0", "", "0", "0", "0", "0", "0", - "0", "B: Placebo", "< 65", "(N=134)", "119 (88.8%)", "", "112 (83.6%)", - "359", "45 (33.6%)", "48 (35.8%)", "42 (31.3%)", "42 (31.3%)", - "49 (36.6%)", "46 (34.3%)", "", "99 (73.9%)", "236", "45 (33.6%)", - "48 (35.8%)", "42 (31.3%)", "42 (31.3%)", "", "103 (76.9%)", - "259", "54 (40.3%)", "48 (35.8%)", "44 (32.8%)", "48 (35.8%)", - "C: Combination", ">= 65", "(N=1)", "1 (100%)", "", "1 (100%)", - "2", "0", "0", "0", "1 (100%)", "1 (100%)", "0", "", "1 (100%)", - "1", "0", "0", "0", "1 (100%)", "", "1 (100%)", "1", "0", "0", - "1 (100%)", "0", "C: Combination", "< 65", "(N=131)", "117 (89.3%)", - "", "115 (87.8%)", "419", "63 (48.1%)", "50 (38.2%)", "51 (38.9%)", - "49 (37.4%)", "42 (32.1%)", "43 (32.8%)", "", "106 (80.9%)", - "294", "63 (48.1%)", "50 (38.2%)", "51 (38.9%)", "49 (37.4%)", - "", "106 (80.9%)", "279", "51 (38.9%)", "50 (38.2%)", "51 (38.9%)", - "55 (42.0%)" - ), - .Dim = c(27L, 7L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet07.R b/tests/testthat/test-table_aet07.R index 17b4cff240..3d73b3a5c8 100644 --- a/tests/testthat/test-table_aet07.R +++ b/tests/testthat/test-table_aet07.R @@ -47,19 +47,8 @@ testthat::test_that("AET07 variant 1 is produced correctly", { decreasing = TRUE ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of deaths", "cl D.1 / dcd D.1.1.1.1", - "cl B.1 / dcd B.1.1.1.1", "B: Placebo", "(N=134)", "70 (52.2%)", - "42 (31.3%)", "49 (36.6%)", "C: Combination", "(N=132)", "75 (56.8%)", - "51 (38.6%)", "43 (32.6%)" - ), - .Dim = c(5L, 3L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET07 variant 2 is produced correctly", { @@ -89,17 +78,6 @@ testthat::test_that("AET07 variant 2 is produced correctly", { decreasing = TRUE ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of deaths", "cl D.1 / dcd D.1.1.1.1", - "cl B.1 / dcd B.1.1.1.1", "A: Drug X", "(N=134)", "0", "0", "0", - "B: Placebo", "(N=134)", "70 (52.2%)", "42 (31.3%)", "49 (36.6%)", - "C: Combination", "(N=132)", "75 (56.8%)", "51 (38.6%)", "43 (32.6%)" - ), - .Dim = 5:4 - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet09.R b/tests/testthat/test-table_aet09.R index 20ba74a0e9..72c264b1ad 100644 --- a/tests/testthat/test-table_aet09.R +++ b/tests/testthat/test-table_aet09.R @@ -39,135 +39,8 @@ testthat::test_that("AET09 variant 1 is produced correctly, AE related to study sort_at_path(path = c("AEBODSYS"), scorefun = cont_n_onecol(4)) %>% sort_at_path(path = c("AEBODSYS", "*", "AEDECOD"), scorefun = score_occurrences) - - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", - "", - "Total number of patients with at least one adverse event related to study drug", - "Overall total number of events related to study drug", - "cl D.2", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd D.2.1.5.3", - "cl D.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd D.1.1.1.1", - "cl B.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd B.1.1.1.1", - "cl C.2", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd C.2.1.2.1", - "cl C.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd C.1.1.1.3", - "A: Drug X", - "(N=134)", - "105 (78.4%)", - "282", - "", - "47 (35.1%)", - "62", - "47 (35.1%)", - "", - "50 (37.3%)", - "61", - "50 (37.3%)", - "", - "47 (35.1%)", - "56", - "47 (35.1%)", - "", - "35 (26.1%)", - "48", - "35 (26.1%)", - "", - "43 (32.1%)", - "55", - "43 (32.1%)", - "B: Placebo", - "(N=134)", - "108 (80.6%)", - "299", - "", - "58 (43.3%)", - "72", - "58 (43.3%)", - "", - "42 (31.3%)", - "51", - "42 (31.3%)", - "", - "49 (36.6%)", - "60", - "49 (36.6%)", - "", - "48 (35.8%)", - "53", - "48 (35.8%)", - "", - "46 (34.3%)", - "63", - "46 (34.3%)", - "C: Combination", - "(N=132)", - "109 (82.6%)", - "336", - "", - "57 (43.2%)", - "74", - "57 (43.2%)", - "", - "51 (38.6%)", - "71", - "51 (38.6%)", - "", - "43 (32.6%)", - "62", - "43 (32.6%)", - "", - "55 (41.7%)", - "65", - "55 (41.7%)", - "", - "43 (32.6%)", - "64", - "43 (32.6%)", - "All Patients", - "(N=400)", - "322 (80.5%)", - "917", - "", - "162 (40.5%)", - "208", - "162 (40.5%)", - "", - "143 (35.8%)", - "183", - "143 (35.8%)", - "", - "139 (34.8%)", - "178", - "139 (34.8%)", - "", - "138 (34.5%)", - "166", - "138 (34.5%)", - "", - "132 (33.0%)", - "182", - "132 (33.0%)" - ), - .Dim = c(24L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AET09 variant 2 is produced correctly, AE related to study drug (including high-level terms)", { @@ -223,168 +96,6 @@ testthat::test_that("AET09 variant 2 is produced correctly, AE related to study sort_at_path(path = c("AEBODSYS", "*", "AEHLT"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("AEBODSYS", "*", "AEHLT", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", - "", - "Total number of patients with at least one adverse event related to study drug", - "Overall total number of events related to study drug", - "cl D.2", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "hlt D.2.1.5", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd D.2.1.5.3", - "cl D.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "hlt D.1.1.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd D.1.1.1.1", - "cl B.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "hlt B.1.1.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd B.1.1.1.1", - "cl C.2", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "hlt C.2.1.2", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd C.2.1.2.1", - "cl C.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "hlt C.1.1.1", - "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", - "dcd C.1.1.1.3", - "A: Drug X", - "(N=134)", - "105 (78.4%)", - "282", - "", - "47 (35.1%)", - "62", - "", - "47 (35.1%)", - "62", - "47 (35.1%)", - "", - "50 (37.3%)", - "61", - "", - "50 (37.3%)", - "61", - "50 (37.3%)", - "", - "47 (35.1%)", - "56", - "", - "47 (35.1%)", - "56", - "47 (35.1%)", - "", - "35 (26.1%)", - "48", - "", - "35 (26.1%)", - "48", - "35 (26.1%)", - "", - "43 (32.1%)", - "55", - "", - "43 (32.1%)", - "55", - "43 (32.1%)", - "B: Placebo", - "(N=134)", - "108 (80.6%)", - "299", - "", - "58 (43.3%)", - "72", - "", - "58 (43.3%)", - "72", - "58 (43.3%)", - "", - "42 (31.3%)", - "51", - "", - "42 (31.3%)", - "51", - "42 (31.3%)", - "", - "49 (36.6%)", - "60", - "", - "49 (36.6%)", - "60", - "49 (36.6%)", - "", - "48 (35.8%)", - "53", - "", - "48 (35.8%)", - "53", - "48 (35.8%)", - "", - "46 (34.3%)", - "63", - "", - "46 (34.3%)", - "63", - "46 (34.3%)", - "C: Combination", - "(N=132)", - "109 (82.6%)", - "336", - "", - "57 (43.2%)", - "74", - "", - "57 (43.2%)", - "74", - "57 (43.2%)", - "", - "51 (38.6%)", - "71", - "", - "51 (38.6%)", - "71", - "51 (38.6%)", - "", - "43 (32.6%)", - "62", - "", - "43 (32.6%)", - "62", - "43 (32.6%)", - "", - "55 (41.7%)", - "65", - "", - "55 (41.7%)", - "65", - "55 (41.7%)", - "", - "43 (32.6%)", - "64", - "", - "43 (32.6%)", - "64", - "43 (32.6%)" - ), - .Dim = c(39L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet09_smq.R b/tests/testthat/test-table_aet09_smq.R index 874c961d0f..047b12dc91 100644 --- a/tests/testthat/test-table_aet09_smq.R +++ b/tests/testthat/test-table_aet09_smq.R @@ -6,7 +6,6 @@ stack_adae_by_smq <- function(adae, smq) { df[["SMQ"]] <- ae_grp df }) - do.call(rbind, l_df) } @@ -33,7 +32,6 @@ testthat::test_that("AET09 variant 1 (AEs related to study drug by SMQ) is produ ) ) - adae <- stack_adae_by_smq(adae, c("SMQ1")) adae_r <- adae[adae$AEREL == "Y", ] @@ -67,27 +65,12 @@ testthat::test_that("AET09 variant 1 (AEs related to study drug by SMQ) is produ sort_at_path(path = c("SMQ"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("SMQ", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one adverse event related to study drug", - "SMQ1", "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", "dcd D.1.1.1.1", - "dcd B.1.1.1.1", "dcd C.1.1.1.3", "A: Drug X", "(N=134)", "91 (67.9%)", - "", "91 (67.9%)", "172", "50 (37.3%)", "47 (35.1%)", "43 (32.1%)", - "B: Placebo", "(N=134)", "90 (67.2%)", "", "90 (67.2%)", "174", - "42 (31.3%)", "49 (36.6%)", "46 (34.3%)", "C: Combination", "(N=132)", - "93 (70.5%)", "", "93 (70.5%)", "197", "51 (38.6%)", "43 (32.6%)", - "43 (32.6%)" - ), - .Dim = c(9L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) -testthat::test_that("AET09 variant 2 (AEs related to study srug by SMQ - ) is produced correctly", { +testthat::test_that( + "AET09 variant 2 (AEs related to study drug by SMQ with customized queries) is produced correctly", { adsl_labels <- formatters::var_labels(adsl) adae_labels <- formatters::var_labels(adae) @@ -107,7 +90,6 @@ testthat::test_that("AET09 variant 2 (AEs related to study srug by SMQ ) ) - adae <- stack_adae_by_smq(adae, c("SMQ1", "SMQ2", "SMQ3")) adae_r <- adae[adae$AEREL == "Y", ] @@ -141,29 +123,6 @@ testthat::test_that("AET09 variant 2 (AEs related to study srug by SMQ sort_at_path(path = c("SMQ"), scorefun = cont_n_allcols) %>% sort_at_path(path = c("SMQ", "*", "AEDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one adverse event related to study drug", - "SMQ1", "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", "dcd D.1.1.1.1", - "dcd B.1.1.1.1", "dcd C.1.1.1.3", - "SMQ2", "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", "dcd D.1.1.1.1", - "SMQ3", "Total number of patients with at least one adverse event related to study drug", - "Total number of events related to study drug", "dcd C.2.1.2.1", - "A: Drug X", "(N=134)", "99 (73.9%)", "", "91 (67.9%)", "172", - "50 (37.3%)", "47 (35.1%)", "43 (32.1%)", "", "50 (37.3%)", "61", - "50 (37.3%)", "", "35 (26.1%)", "48", "35 (26.1%)", "B: Placebo", - "(N=134)", "98 (73.1%)", "", "90 (67.2%)", "174", "42 (31.3%)", - "49 (36.6%)", "46 (34.3%)", "", "42 (31.3%)", "51", "42 (31.3%)", - "", "48 (35.8%)", "53", "48 (35.8%)", "C: Combination", "(N=132)", - "102 (77.3%)", "", "93 (70.5%)", "197", "51 (38.6%)", "43 (32.6%)", - "43 (32.6%)", "", "51 (38.6%)", "71", "51 (38.6%)", "", "55 (41.7%)", - "65", "55 (41.7%)" - ), - .Dim = c(17L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aet10.R b/tests/testthat/test-table_aet10.R index f4a4660b47..56a156e7ab 100644 --- a/tests/testthat/test-table_aet10.R +++ b/tests/testthat/test-table_aet10.R @@ -3,7 +3,6 @@ adsl <- adsl_raw adae <- adae_raw - testthat::test_that("AET10 default variant is produced correctly", { result1 <- basic_table() %>% split_cols_by(var = "ARM", split_fun = add_overall_level("All Patients", first = FALSE)) %>% @@ -18,21 +17,8 @@ testthat::test_that("AET10 default variant is produced correctly", { ) ) - result3 <- sort_at_path(result2, path = c("AEDECOD"), scorefun = score_occurrences) - - result_matrix <- to_string_matrix(result3) - - expected_matrix <- structure( - c( - "", "", "dcd D.2.1.5.3", "dcd A.1.1.1.1", "dcd B.2.2.3.1", - "dcd C.2.1.2.1", "A: Drug X", "(N=134)", "47 (35.1%)", "50 (37.3%)", - "48 (35.8%)", "35 (26.1%)", "B: Placebo", "(N=134)", "58 (43.3%)", - "45 (33.6%)", "54 (40.3%)", "48 (35.8%)", "C: Combination", "(N=132)", - "57 (43.2%)", "63 (47.7%)", "51 (38.6%)", "55 (41.7%)", "All Patients", - "(N=400)", "162 (40.5%)", "158 (39.5%)", "153 (38.2%)", "138 (34.5%)" - ), - .Dim = 6:5 - ) + result <- sort_at_path(result2, path = c("AEDECOD"), scorefun = score_occurrences) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_aovt01.R b/tests/testthat/test-table_aovt01.R index b8ed08baf4..eba926ac03 100644 --- a/tests/testthat/test-table_aovt01.R +++ b/tests/testthat/test-table_aovt01.R @@ -28,23 +28,9 @@ testthat::test_that("AOVT01 variant with single endpoint is produced correctly", table_names = "adjusted" ) %>% build_table(adqs_single, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Unadjusted comparison", "n", "Mean", "Difference in Means", "95% CI", "p-value", - "Adjusted comparison (covariates BASE and STRATA1)", "n", "Adjusted Mean", - "Difference in Adjusted Means", "95% CI", "p-value", - "ARM A", "(N=134)", "", "68", "3.68", "", "", "", "", "68", "4.06", "", "", "", - "ARM B", "(N=134)", "", "73", "5.07", "1.38", "(-2.76, 5.53)", "0.5113", "", - "73", "3.57", "-0.49", "(-3.28, 2.29)", "0.7277", - "ARM C", "(N=132)", "", "62", "3.09", "-0.59", "(-4.91, 3.73)", "0.7873", "", - "62", "3.34", "-0.72", "(-3.57, 2.12)", "0.6165" - ), - .Dim = c(14L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("AOVT01 variant with multiple endpoints is produced correctly", { @@ -61,31 +47,7 @@ testthat::test_that("AOVT01 variant with multiple endpoints is produced correctl conf_level = 0.95, var_labels = "Adjusted mean" ) %>% build_table(adqs_multi, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "BFIALL", "Adjusted mean", "n", "Adjusted Mean", - "Difference in Adjusted Means", "95% CI", "p-value", - "FATIGI", "Adjusted mean", "n", "Adjusted Mean", "Difference in Adjusted Means", "95% CI", "p-value", - "FKSI-FWB", "Adjusted mean", "n", "Adjusted Mean", "Difference in Adjusted Means", "95% CI", "p-value", - "FKSI-TSE", "Adjusted mean", "n", "Adjusted Mean", "Difference in Adjusted Means", "95% CI", "p-value", - "FKSIALL", "Adjusted mean", "n", "Adjusted Mean", "Difference in Adjusted Means", "95% CI", "p-value", - "ARM A", "(N=134)", "", "", "134", "4.47", "", "", "", "", "", "134", "5.42", "", "", "", "", "", "134", "4.29", - "", "", "", "", "", "134", "4.70", "", "", "", "", "", "134", "5.03", "", "", "", - "ARM B", "(N=134)", "", "", "134", "6.33", "1.85", "(-0.14, 3.85)", "0.0679", "", "", - "134", "4.83", "-0.59", "(-2.58, 1.41)", "0.5644", "", "", - "134", "3.51", "-0.79", "(-2.71, 1.14)", "0.4221", "", "", - "134", "3.84", "-0.86", "(-2.80, 1.09)", "0.3858", "", "", - "134", "5.82", "0.79", "(-1.17, 2.76)", "0.4288", - "ARM C", "(N=132)", "", "", "132", "4.02", "-0.46", "(-2.45, 1.54)", "0.6539", "", "", - "132", "4.56", "-0.86", "(-2.87, 1.15)", "0.4026", "", "", - "132", "3.06", "-1.24", "(-3.17, 0.69)", "0.2088", "", "", - "132", "4.45", "-0.25", "(-2.20, 1.70)", "0.8007", "", "", - "132", "6.44", "1.42", "(-0.56, 3.39)", "0.1591" - ), - .Dim = c(37L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_cmt01.R b/tests/testthat/test-table_cmt01.R index 76ba7bca7c..87a261181c 100644 --- a/tests/testthat/test-table_cmt01.R +++ b/tests/testthat/test-table_cmt01.R @@ -32,36 +32,8 @@ testthat::test_that("CMT01 default variant (Concomitant medications) is produced build_table(adcm_c, alt_counts_df = adsl) %>% sort_at_path(path = c("CMCLAS", "*", "CMDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one treatment", - "Total number of treatments", "medcl A", - "Total number of patients with at least one treatment", - "Total number of treatments", "medname A_2/3", "medname A_3/3", "medcl B", - "Total number of patients with at least one treatment", - "Total number of treatments", "medname B_1/4", "medname B_4/4", "medcl C", - "Total number of patients with at least one treatment", - "Total number of treatments", "medname C_2/2", "medname C_1/2", - "A: Drug X", "(N=134)", "117 (87.3%)", "832", "", "75 (56.0%)", "192", - "53 (39.6%)", "45 (33.6%)", "", "83 (61.9%)", "291", "52 (38.8%)", - "50 (37.3%)", "", "82 (61.2%)", "349", "52 (38.8%)", "51 (38.1%)", - "B: Placebo", "(N=134)", "116 (86.6%)", "857", "", "79 (59.0%)", "203", - "50 (37.3%)", "54 (40.3%)", "", "74 (55.2%)", "301", "57 (42.5%)", - "45 (33.6%)", "", "84 (62.7%)", "353", "58 (43.3%)", "50 (37.3%)", - "C: Combination", "(N=132)", "116 (87.9%)", "925", "", "81 (61.4%)", - "207", "56 (42.4%)", "48 (36.4%)", "", "88 (66.7%)", "328", "59 (44.7%)", - "55 (41.7%)", "", "89 (67.4%)", "390", "60 (45.5%)", "56 (42.4%)", - "All Patients", "(N=400)", "349 (87.2%)", "2614", "", "235 (58.8%)", - "602", "159 (39.8%)", "147 (36.8%)", "", "245 (61.3%)", "920", - "168 (42.0%)", "150 (37.5%)", "", "255 (63.7%)", "1092", "170 (42.5%)", - "157 (39.2%)" - ), - .Dim = c(19L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("CMT01 variant 1 (prior medications) is produced correctly", { @@ -95,29 +67,8 @@ testthat::test_that("CMT01 variant 1 (prior medications) is produced correctly", build_table(adcm_p, alt_counts_df = adsl) %>% sort_at_path(path = c("CMCLAS", "*", "CMDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one treatment", - "Total number of treatments", "medcl A", - "Total number of patients with at least one treatment", - "Total number of treatments", "medname A_1/3", "medcl B", - "Total number of patients with at least one treatment", - "Total number of treatments", "medname B_2/4", "medname B_3/4", - "A: Drug X", "(N=134)", "89 (66.4%)", "322", "", "54 (40.3%)", "71", - "54 (40.3%)", "", "76 (56.7%)", "251", "52 (38.8%)", "47 (35.1%)", - "B: Placebo", "(N=134)", "95 (70.9%)", "354", "", "49 (36.6%)", "70", - "49 (36.6%)", "", "80 (59.7%)", "284", "55 (41.0%)", "47 (35.1%)", - "C: Combination", "(N=132)", "106 (80.3%)", "395", "", "69 (52.3%)", - "99", "69 (52.3%)", "", "81 (61.4%)", "296", "56 (42.4%)", "52 (39.4%)", - "All Patients", "(N=400)", "290 (72.5%)", "1071", "", "172 (43.0%)", "240", - "172 (43.0%)", "", "237 (59.2%)", "831", "163 (40.8%)", "146 (36.5%)" - ), - .Dim = c(13L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("CMT01 variant 3 (Concomitant medications) is produced correctly", { @@ -149,33 +100,8 @@ testthat::test_that("CMT01 variant 3 (Concomitant medications) is produced corre build_table(adcm_c, alt_counts_df = adsl) %>% sort_at_path(path = c("CMCLAS", "*", "CMDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one treatment", - "Total number of treatments", "medcl A", - "Total number of patients with at least one treatment", "medname A_2/3", - "medname A_3/3", "medcl B", - "Total number of patients with at least one treatment", "medname B_1/4", - "medname B_4/4", "medcl C", - "Total number of patients with at least one treatment", "medname C_2/2", - "medname C_1/2", "A: Drug X", "(N=134)", "117 (87.3%)", "832", "", - "75 (56.0%)", "53 (39.6%)", "45 (33.6%)", "", "83 (61.9%)", "52 (38.8%)", - "50 (37.3%)", "", "82 (61.2%)", "52 (38.8%)", "51 (38.1%)", "B: Placebo", - "(N=134)", "116 (86.6%)", "857", "", "79 (59.0%)", "50 (37.3%)", "54 (40.3%)", - "", "74 (55.2%)", "57 (42.5%)", "45 (33.6%)", "", "84 (62.7%)", "58 (43.3%)", - "50 (37.3%)", "C: Combination", "(N=132)", "116 (87.9%)", "925", "", "81 (61.4%)", - "56 (42.4%)", "48 (36.4%)", "", "88 (66.7%)", "59 (44.7%)", "55 (41.7%)", "", - "89 (67.4%)", "60 (45.5%)", "56 (42.4%)", "All Patients", "(N=400)", - "349 (87.2%)", "2614", "", "235 (58.8%)", "159 (39.8%)", "147 (36.8%)", - "", "245 (61.3%)", "168 (42.0%)", "150 (37.5%)", "", "255 (63.7%)", - "170 (42.5%)", "157 (39.2%)" - ), - .Dim = c(16L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("CMT01 variant 4 (Concomitant medications) is produced correctly", { @@ -205,33 +131,6 @@ testthat::test_that("CMT01 variant 4 (Concomitant medications) is produced corre sort_at_path(path = c("CMCLAS", "*", "CMDECOD"), scorefun = score_occurrences, decreasing = TRUE) %>% sort_at_path(path = c("CMCLAS"), scorefun = cont_n_onecol(4), decreasing = TRUE) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one treatment (%)", - "Total number of treatments", "medcl C", - "Total number of patients with at least one treatment (%)", - "Total number of treatments", "medname C_2/2", "medname C_1/2", "medcl B", - "Total number of patients with at least one treatment (%)", - "Total number of treatments", "medname B_1/4", "medname B_4/4", "medcl A", - "Total number of patients with at least one treatment (%)", - "Total number of treatments", "medname A_2/3", "medname A_3/3", - "A: Drug X", "(N=134)", "117 (87.3%)", "832", "", "82 (61.2%)", "349", - "52 (38.8%)", "51 (38.1%)", "", "83 (61.9%)", "291", "52 (38.8%)", - "50 (37.3%)", "", "75 (56.0%)", "192", "53 (39.6%)", "45 (33.6%)", "B: Placebo", - "(N=134)", "116 (86.6%)", "857", "", "84 (62.7%)", "353", "58 (43.3%)", - "50 (37.3%)", "", "74 (55.2%)", "301", "57 (42.5%)", "45 (33.6%)", "", - "79 (59.0%)", "203", "50 (37.3%)", "54 (40.3%)", "C: Combination", "(N=132)", - "116 (87.9%)", "925", "", "89 (67.4%)", "390", "60 (45.5%)", "56 (42.4%)", - "", "88 (66.7%)", "328", "59 (44.7%)", "55 (41.7%)", "", "81 (61.4%)", - "207", "56 (42.4%)", "48 (36.4%)", "All Patients", "(N=400)", "349 (87.2%)", - "2614", "", "255 (63.7%)", "1092", "170 (42.5%)", "157 (39.2%)", "", - "245 (61.3%)", "920", "168 (42.0%)", "150 (37.5%)", "", "235 (58.8%)", - "602", "159 (39.8%)", "147 (36.8%)" - ), - .Dim = c(19L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_cmt02_pt.R b/tests/testthat/test-table_cmt02_pt.R index 6bd59946cb..8bbbe7055d 100644 --- a/tests/testthat/test-table_cmt02_pt.R +++ b/tests/testthat/test-table_cmt02_pt.R @@ -22,27 +22,6 @@ testthat::test_that("CMT02_PT default variant is produced correctly", { build_table(adcm, alt_counts_df = adsl) %>% sort_at_path(path = c("CMDECOD"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one event", - "Total number of events", "medname A_1/3", "medname C_2/2", "medname B_1/4", - "medname B_2/4", "medname A_2/3", "medname C_1/2", "medname B_4/4", - "medname A_3/3", "medname B_3/4", "A: Drug X", "(N=134)", "122 (91.0%)", - "609", "54 (40.3%)", "52 (38.8%)", "52 (38.8%)", "52 (38.8%)", - "53 (39.6%)", "51 (38.1%)", "50 (37.3%)", "45 (33.6%)", "47 (35.1%)", - "B: Placebo", "(N=134)", "123 (91.8%)", "622", "49 (36.6%)", - "58 (43.3%)", "57 (42.5%)", "55 (41.0%)", "50 (37.3%)", "50 (37.3%)", - "45 (33.6%)", "54 (40.3%)", "47 (35.1%)", "C: Combination", "(N=132)", - "120 (90.9%)", "703", "69 (52.3%)", "60 (45.5%)", "59 (44.7%)", - "56 (42.4%)", "56 (42.4%)", "56 (42.4%)", "55 (41.7%)", "48 (36.4%)", - "52 (39.4%)", "All Patients", "(N=400)", "365 (91.2%)", "1934", - "172 (43.0%)", "170 (42.5%)", "168 (42.0%)", "163 (40.8%)", "159 (39.8%)", - "157 (39.2%)", "150 (37.5%)", "147 (36.8%)", "146 (36.5%)" - ), - .Dim = c(13L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_coxt01.R b/tests/testthat/test-table_coxt01.R index e3e1b24548..43e684e699 100644 --- a/tests/testthat/test-table_coxt01.R +++ b/tests/testthat/test-table_coxt01.R @@ -32,27 +32,17 @@ testthat::test_that("1. Cox Regression", { data = adtte_f ) df <- broom::tidy(mod1) + result <- basic_table() %>% split_rows_by("effect") %>% split_rows_by("term", child_labels = "hidden") %>% summarize_coxreg(conf_level = .95) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Treatment:", "ARM A vs control (ARM B)", "Covariate:", - "Sex", "Race", "Age", "n", "", "247", "", "247", "247", "247", - "Hazard Ratio", "", "0.70", "", "0.71", "0.70", "0.70", "95% CI", - "", "(0.51, 0.96)", "", "(0.52, 0.98)", "(0.51, 0.97)", "(0.51, 0.97)", - "p-value", "", "0.0293", "", "0.0370", "0.0318", "0.0321" - ), - .Dim = c(7L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) - testthat::test_that("2. Cox Regression (with Interaction Term)", { mod2 <- fit_coxreg_univar( variables = list( @@ -63,29 +53,15 @@ testthat::test_that("2. Cox Regression (with Interaction Term)", { control = control_coxreg(interaction = TRUE) ) df <- broom::tidy(mod2) + result <- basic_table() %>% split_rows_by("effect") %>% split_rows_by("term", child_labels = "hidden") %>% summarize_coxreg(conf_level = .95, vars = c("n", "hr", "ci", "pval", "pval_inter")) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Treatment:", "ARM A vs control (ARM B)", "Covariate:", - "Sex", " F", " M", "Race", " ASIAN", " BLACK OR AFRICAN AMERICAN", - " WHITE", "Age", " 34", "n", "", "247", "", "247", "", "", - "247", "", "", "", "247", "", "Hazard Ratio", "", "0.70", "", - "", "0.64", "0.82", "", "0.75", "0.66", "0.65", "", "0.70", "95% CI", - "", "(0.51, 0.96)", "", "", "(0.42, 0.98)", "(0.50, 1.35)", "", - "(0.48, 1.16)", "(0.34, 1.28)", "(0.33, 1.27)", "", "(0.51, 0.97)", - "p-value", "", "0.0293", "", "", "", "", "", "", - "", "", "", "", "Interaction p-value", "", "", "", "0.4635", - "", "", "0.9197", "", "", "", "0.8626", "" - ), - .Dim = c(13L, 6L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) @@ -100,32 +76,15 @@ testthat::test_that("3. Cox Regression (specifying covariates)", { at = list(AGE = c(30, 40, 50)) ) df <- broom::tidy(mod3) + result <- basic_table() %>% split_rows_by("effect") %>% split_rows_by("term", child_labels = "hidden") %>% summarize_coxreg(conf_level = .95, vars = c("n", "hr", "ci", "pval", "pval_inter")) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Treatment:", "ARM A vs control (ARM B)", "Covariate:", - "Sex", " F", " M", "Race", " ASIAN", " BLACK OR AFRICAN AMERICAN", - " WHITE", "Age", " 30", " 40", " 50", "n", "", "247", "", - "247", "", "", "247", "", "", "", "247", "", "", "", "Hazard Ratio", - "", "0.70", "", "", "0.64", "0.82", "", "0.75", "0.66", "0.65", - "", "0.69", "0.72", "0.75", "95% CI", "", "(0.51, 0.96)", "", - "", "(0.42, 0.98)", "(0.50, 1.35)", "", "(0.48, 1.16)", "(0.34, 1.28)", - "(0.33, 1.27)", "", "(0.48, 1.00)", "(0.48, 1.08)", "(0.35, 1.61)", - "p-value", "", "0.0293", "", "", "", "", "", "", - "", "", "", "", "", "", "Interaction p-value", "", "", - "", "0.4635", "", "", "0.9197", "", "", "", "0.8626", "", "", - "" - ), - .Dim = c(15L, 6L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) @@ -145,30 +104,13 @@ testthat::test_that("4. Cox Regression (setting strata, ties, and alpha level)", at = list(AGE = c(30, 40, 50)) ) df <- broom::tidy(mod4) + result <- basic_table() %>% split_rows_by("effect") %>% split_rows_by("term", child_labels = "hidden") %>% summarize_coxreg(conf_level = conf_level, vars = c("n", "hr", "ci", "pval", "pval_inter")) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Treatment:", "ARM A vs control (ARM B)", "Covariate:", - "Sex", " F", " M", "Race", " ASIAN", " BLACK OR AFRICAN AMERICAN", - " WHITE", "Age", " 30", " 40", " 50", "n", "", "247", "", - "247", "", "", "247", "", "", "", "247", "", "", "", "Hazard Ratio", - "", "0.70", "", "", "0.64", "0.82", "", "0.75", "0.66", "0.65", - "", "0.69", "0.72", "0.75", "90% CI", "", "(0.53, 0.92)", "", - "", "(0.42, 0.98)", "(0.50, 1.35)", "", "(0.48, 1.16)", "(0.34, 1.28)", - "(0.33, 1.27)", "", "(0.51, 0.94)", "(0.51, 1.02)", "(0.39, 1.42)", - "p-value", "", "0.0293", "", "", "", "", "", "", - "", "", "", "", "", "", "Interaction p-value", "", "", - "", "0.4635", "", "", "0.9197", "", "", "", "0.8626", "", "", - "" - ), - .Dim = c(15L, 6L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_coxt02.R b/tests/testthat/test-table_coxt02.R index c606698ad0..981f5849cc 100644 --- a/tests/testthat/test-table_coxt02.R +++ b/tests/testthat/test-table_coxt02.R @@ -34,24 +34,14 @@ testthat::test_that("COXT02 default variant 1 is produced correctly", { data = adtte_f ) df <- broom::tidy(multivar_model) + result <- basic_table() %>% split_rows_by("term", child_labels = "hidden") %>% summarize_coxreg(multivar = TRUE, conf_level = .95) %>% build_table(df) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "ARMCD (reference = ARM B)", "ARM A", "ARM C", - "Sex (reference = F)", "M", "Age", "Hazard Ratio", "", "0.72", - "1.93", "", "1.17", "1.01", "95% CI", "", "(0.52, 0.99)", "(1.44, 2.59)", - "", "(0.91, 1.51)", "(0.99, 1.02)", "p-value", "<0.0001", "0.0417", - "<0.0001", "", "0.2142", "0.4785" - ), - .Dim = c(7L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("COXT02 variant 5 is produced correctly", { @@ -67,21 +57,12 @@ testthat::test_that("COXT02 variant 5 is produced correctly", { data = adtte_f ) df <- broom::tidy(multivar_model) + result <- basic_table() %>% split_rows_by("term", child_labels = "hidden") %>% summarize_coxreg(multivar = TRUE, conf_level = 0.9, vars = c("hr", "ci")) %>% build_table(df) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "ARMCD (reference = ARM B)", "ARM A", "ARM C", - "Sex (reference = F)", "M", "Age", "Hazard Ratio", "", "0.72", - "1.96", "", "1.21", "1.01", "90% CI", "", "(0.55, 0.95)", "(1.52, 2.51)", - "", "(0.98, 1.49)", "(0.99, 1.02)" - ), - .Dim = c(7L, 3L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_disclosures.R b/tests/testthat/test-table_disclosures.R index 0cc3e884d7..39577eb4d3 100644 --- a/tests/testthat/test-table_disclosures.R +++ b/tests/testthat/test-table_disclosures.R @@ -103,26 +103,9 @@ testthat::test_that("Patient Disposition table is produced correctly", { denom = "N_col" ) %>% build_table(adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Started Study", "Completed Study", "Discontinued Study", - "ADVERSE EVENT", "DEATH", "LACK OF EFFICACY", "PHYSICIAN DECISION", - "PROTOCOL VIOLATION", "WITHDRAWAL BY PARENT/GUARDIAN", "WITHDRAWAL BY SUBJECT", - "A: Drug X", "(N=134)", "134 (100.00%)", "68 (50.75%)", "42 (31.34%)", - "3 (2.24%)", "25 (18.66%)", "2 (1.49%)", "2 (1.49%)", "5 (3.73%)", - "4 (2.99%)", "1 (0.75%)", "B: Placebo", "(N=134)", "134 (100.00%)", - "66 (49.25%)", "40 (29.85%)", "6 (4.48%)", "23 (17.16%)", "2 (1.49%)", - "3 (2.24%)", "3 (2.24%)", "2 (1.49%)", "1 (0.75%)", "C: Combination", - "(N=132)", "132 (100.00%)", "73 (55.30%)", "38 (28.79%)", "5 (3.79%)", - "22 (16.67%)", "3 (2.27%)", "2 (1.52%)", "4 (3.03%)", "1 (0.76%)", - "1 (0.76%)", "All Patients", "(N=400)", "400 (100.00%)", "207 (51.75%)", - "120 (30.00%)", "14 (3.50%)", "70 (17.50%)", "7 (1.75%)", "7 (1.75%)", - "12 (3.00%)", "7 (1.75%)", "3 (0.75%)" - ), - .Dim = c(12L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Demographic table is produced correctly", { @@ -142,35 +125,8 @@ testthat::test_that("Demographic table is produced correctly", { build_table(adsl) %>% prune_table() - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Age (yr)", "n", "Mean (SD)", "Median", "Min - Max", - "Age group (yr)", "n", "< 65 yrs", ">= 65 yrs", "Sex", "n", "F", - "M", "Race", "n", "ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE", - "AMERICAN INDIAN OR ALASKA NATIVE", "MULTIPLE", "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER", - "Ethnicity", "n", "Ethnicity 1", "Ethnicity 2", "Unknown", "A: Drug X", - "(N=134)", "", "134", "33.8 (6.6)", "33.0", "21.0 - 50.0", "", "134", - "134 (100%)", "0", "", "134", "79 (59%)", "55 (41%)", "", "134", - "68 (50.7%)", "31 (23.1%)", "27 (20.1%)", "8 (6%)", "0", "0", - "", "134", "50 (37.3%)", "46 (34.3%)", "38 (28.4%)", "B: Placebo", - "(N=134)", "", "134", "35.4 (7.9)", "35.0", "21.0 - 62.0", "", "134", - "134 (100%)", "0", "", "134", "82 (61.2%)", "52 (38.8%)", "", - "134", "67 (50%)", "28 (20.9%)", "26 (19.4%)", "11 (8.2%)", "1 (0.7%)", - "1 (0.7%)", "", "134", "51 (38.1%)", "38 (28.4%)", "45 (33.6%)", - "C: Combination", "(N=132)", "", "132", "35.4 (7.7)", "35.0", "20.0 - 69.0", - "", "132", "131 (99.2%)", "1 (0.8%)", "", "132", "70 (53%)", - "62 (47%)", "", "132", "73 (55.3%)", "32 (24.2%)", "21 (15.9%)", - "6 (4.5%)", "0", "0", "", "132", "46 (34.8%)", "41 (31.1%)", - "45 (34.1%)", "All Patients", "(N=400)", "", "400", "34.9 (7.4)", - "34.0", "20.0 - 69.0", "", "400", "399 (99.8%)", "1 (0.2%)", "", "400", - "231 (57.8%)", "169 (42.2%)", "", "400", "208 (52%)", "91 (22.8%)", - "74 (18.5%)", "25 (6.2%)", "1 (0.2%)", "1 (0.2%)", "", "400", - "147 (36.8%)", "125 (31.2%)", "128 (32%)" - ), - .Dim = c(28L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Enrollment by Country Table is produced correctly", { @@ -181,25 +137,8 @@ testthat::test_that("Enrollment by Country Table is produced correctly", { summarize_vars("COUNTRY", .formats = c(count_fraction = "xx (xx.xx%)")) %>% build_table(adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "n", "CHN", "USA", "BRA", "PAK", "NGA", "RUS", - "JPN", "GBR", "CAN", "CHE", "A: Drug X", "(N=134)", "134", "74 (55.22%)", - "10 (7.46%)", "13 (9.70%)", "12 (8.96%)", "8 (5.97%)", "5 (3.73%)", - "5 (3.73%)", "4 (2.99%)", "3 (2.24%)", "0 (0.00%)", "B: Placebo", - "(N=134)", "134", "81 (60.45%)", "13 (9.70%)", "7 (5.22%)", "9 (6.72%)", - "7 (5.22%)", "8 (5.97%)", "4 (2.99%)", "3 (2.24%)", "2 (1.49%)", - "0 (0.00%)", "C: Combination", "(N=132)", "132", "64 (48.48%)", - "17 (12.88%)", "10 (7.58%)", "10 (7.58%)", "11 (8.33%)", "6 (4.55%)", - "9 (6.82%)", "2 (1.52%)", "3 (2.27%)", "0 (0.00%)", "All Patients", - "(N=400)", "400", "219 (54.75%)", "40 (10.00%)", "30 (7.50%)", "31 (7.75%)", - "26 (6.50%)", "19 (4.75%)", "18 (4.50%)", "9 (2.25%)", "8 (2.00%)", - "0 (0.00%)" - ), - .Dim = c(13L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Death table is produced correctly", { @@ -216,17 +155,8 @@ testthat::test_that("Death table is produced correctly", { ) %>% build_table(adae, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Total Number of Deaths", "A: Drug X", "(N=134)", - "76 (62.30%)", "B: Placebo", "(N=134)", "70 (56.91%)", "C: Combination", - "(N=132)", "75 (62.50%)", "All Patients", "(N=400)", "221 (60.55%)" - ), - .Dim = c(3L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Table of Serious Adverse Events is produced correctly (for one specific treatment arm)", { @@ -253,21 +183,8 @@ testthat::test_that("Table of Serious Adverse Events is produced correctly (for ) %>% build_table(adae_serious_arm) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Total number of patients with at least one serious adverse event", - "cl A.1", "dcd A.1.1.1.2", "cl B.1", "dcd B.1.1.1.1", "cl B.2", - "dcd B.2.2.3.1", "cl D.1", "dcd D.1.1.1.1", "Patients (All)", - "104", "", "48", "", "47", "", "48", "", "50", "Events (All)", - "", "", "68", "", "56", "", "64", "", "61", "Events (Related)", - "", "", "0", "", "56", "", "0", "", "61", "Events (Fatal)", - "", "", "0", "", "56", "", "0", "", "61", "Events (Fatal & Related)", - "", "", "0", "", "56", "", "0", "", "61" - ), - .Dim = c(10L, 6L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Table of Non-Serious Adverse Events is produced correctly", { @@ -288,25 +205,6 @@ testthat::test_that("Table of Non-Serious Adverse Events is produced correctly", ) %>% build_table(adae_trim, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "Total number of patients with at least one non-SAE and number of events", - "cl A.1", "dcd A.1.1.1.1", "cl B.2", "dcd B.2.1.2.1", "cl C.1", - "dcd C.1.1.1.3", "cl C.2", "dcd C.2.1.2.1", "cl D.1", "dcd D.1.1.4.2", - "cl D.2", "dcd D.2.1.5.3", "A: Drug X", "Patients (All)", "(N=134)", - "106", "", "50", "", "49", "", "43", "", "35", "", "48", "", - "47", "A: Drug X", "Events (All)", "(N=134)", "360", "", "64", - "", "65", "", "55", "", "48", "", "66", "", "62", "B: Placebo", - "Patients (All)", "(N=134)", "112", "", "45", "", "44", "", "46", - "", "48", "", "42", "", "58", "B: Placebo", "Events (All)", "(N=134)", - "367", "", "62", "", "62", "", "63", "", "53", "", "55", "", - "72", "C: Combination", "Patients (All)", "(N=132)", "112", "", - "63", "", "52", "", "43", "", "55", "", "50", "", "57", "C: Combination", - "Events (All)", "(N=132)", "421", "", "88", "", "66", "", "64", - "", "65", "", "64", "", "74" - ), - .Dim = c(16L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_dmt01.R b/tests/testthat/test-table_dmt01.R index 87ff3c4874..2461dc8140 100644 --- a/tests/testthat/test-table_dmt01.R +++ b/tests/testthat/test-table_dmt01.R @@ -23,23 +23,19 @@ testthat::test_that("DMT01 default and alternative variants are produced correct levels = c("18-40", "41-64", ">=65") )) - # Obtain SBP, DBP and weight. - get_param_advs <- function(pname, plabel) { ds <- advs %>% dplyr::filter(PARAM == plabel & AVISIT == "BASELINE") %>% dplyr::select(USUBJID, AVAL) - colnames(ds) <- c("USUBJID", pname) - ds } adsl <- adsl %>% - dplyr::inner_join(get_param_advs("SBP", "Systolic Blood Pressure")) %>% - dplyr::inner_join(get_param_advs("DBP", "Diastolic Blood Pressure")) %>% - dplyr::inner_join(get_param_advs("WGT", "Weight")) + dplyr::inner_join(get_param_advs("SBP", "Systolic Blood Pressure"), by = "USUBJID") %>% + dplyr::inner_join(get_param_advs("DBP", "Diastolic Blood Pressure"), by = "USUBJID") %>% + dplyr::inner_join(get_param_advs("WGT", "Weight"), by = "USUBJID") vars <- c("AGE", "AGEGRP", "SEX", "RACE", "WGT", "SBP", "DBP") var_labels <- c( @@ -62,47 +58,8 @@ testthat::test_that("DMT01 default and alternative variants are produced correct ) %>% build_table(adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Age (yr)", "n", "Mean (SD)", "Median", "Min - Max", - "Age group (yr)", "n", "18-40", "41-64", ">=65", "Sex", "n", - "Female", "Male", "Race", "n", "ASIAN", "BLACK OR AFRICAN AMERICAN", - "WHITE", "AMERICAN INDIAN OR ALASKA NATIVE", "MULTIPLE", "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER", - "OTHER", "UNKNOWN", "Weight (kg) at Baseline", "n", "Mean (SD)", - "Median", "Min - Max", "Systolic Blood Pressure at Baseline", - "n", "Mean (SD)", "Median", "Min - Max", "Diastolic Blood Pressure at Baseline", - "n", "Mean (SD)", "Median", "Min - Max", "A: Drug X", "(N=134)", - "", "134", "33.8 (6.6)", "33.0", "21.0 - 50.0", "", "134", "113 (84.3%)", - "21 (15.7%)", "0", "", "134", "79 (59%)", "55 (41%)", "", - "134", "68 (50.7%)", "31 (23.1%)", "27 (20.1%)", "8 (6%)", "0", - "0", "0", "0", "", "134", "50.7 (7.9)", "49.8", - "33.3 - 71.9", "", "134", "49.4 (8.5)", "48.3", "24.3 - 71.1", - "", "134", "48.6 (8.0)", "48.4", "27.7 - 64.6", "B: Placebo", "(N=134)", - "", "134", "35.4 (7.9)", "35.0", "21.0 - 62.0", "", "134", "103 (76.9%)", - "31 (23.1%)", "0", "", "134", "82 (61.2%)", "52 (38.8%)", - "", "134", "67 (50%)", "28 (20.9%)", "26 (19.4%)", "11 (8.2%)", - "1 (0.7%)", "1 (0.7%)", "0", "0", "", "134", "49.9 (8.3)", - "50.7", "27.9 - 69.8", "", "134", "50.2 (8.5)", "50.0", "24.4 - 71.1", - "", "134", "50.4 (7.9)", "50.2", "21.7 - 67.5", "C: Combination", - "(N=132)", "", "132", "35.4 (7.7)", "35.0", "20.0 - 69.0", "", "132", - "106 (80.3%)", "25 (18.9%)", "1 (0.8%)", "", "132", "70 (53%)", - "62 (47%)", "", "132", "73 (55.3%)", "32 (24.2%)", "21 (15.9%)", - "6 (4.5%)", "0", "0", "0", "0", "", "132", - "49.4 (7.5)", "49.6", "29.4 - 65.1", "", "132", "48.5 (7.2)", - "49.2", "26.2 - 63.4", "", "132", "51.1 (7.8)", "50.8", "29.7 - 71.4", - "All Patients", "(N=400)", "", "400", "34.9 (7.4)", "34.0", "20.0 - 69.0", - "", "400", "322 (80.5%)", "77 (19.2%)", "1 (0.2%)", "", "400", - "231 (57.8%)", "169 (42.2%)", "", "400", "208 (52%)", "91 (22.8%)", - "74 (18.5%)", "25 (6.2%)", "1 (0.2%)", "1 (0.2%)", "0", - "0", "", "400", "50.0 (7.9)", "50.1", "27.9 - 71.9", "", "400", - "49.4 (8.1)", "49.2", "24.3 - 71.1", "", "400", "50.0 (8.0)", "50.0", - "21.7 - 71.4" - ), - .Dim = c(41L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Alternative variant for DMT01 (Optional Subgrouping Analysis). result <- basic_table() %>% @@ -113,66 +70,6 @@ testthat::test_that("DMT01 default and alternative variants are produced correct summarize_vars(vars = vars[1:3], var_labels = var_labels[1:3], nested = FALSE) %>% build_table(adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Female", "Race", "n", "ASIAN", "BLACK OR AFRICAN AMERICAN", - "WHITE", "AMERICAN INDIAN OR ALASKA NATIVE", "MULTIPLE", "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER", - "OTHER", "UNKNOWN", "Weight (kg) at Baseline", "n", "Mean (SD)", - "Median", "Min - Max", "Systolic Blood Pressure at Baseline", - "n", "Mean (SD)", "Median", "Min - Max", "Diastolic Blood Pressure at Baseline", - "n", "Mean (SD)", "Median", "Min - Max", "Male", "Race", "n", - "ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE", "AMERICAN INDIAN OR ALASKA NATIVE", - "MULTIPLE", "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER", "OTHER", - "UNKNOWN", "Weight (kg) at Baseline", "n", "Mean (SD)", "Median", - "Min - Max", "Systolic Blood Pressure at Baseline", "n", "Mean (SD)", - "Median", "Min - Max", "Diastolic Blood Pressure at Baseline", - "n", "Mean (SD)", "Median", "Min - Max", "Age (yr)", "n", "Mean (SD)", - "Median", "Min - Max", "Age group (yr)", "n", "18-40", "41-64", - ">=65", "Sex", "n", "Female", "Male", "A: Drug X", "(N=134)", - "", "", "79", "41 (51.9%)", "18 (22.8%)", "17 (21.5%)", "3 (3.8%)", - "0", "0", "0", "0", "", "79", "50.3 (7.0)", - "50.1", "35.9 - 69.9", "", "79", "49.7 (7.9)", "48.7", "25.4 - 71.1", - "", "79", "48.4 (8.8)", "48.2", "27.7 - 64.6", "", "", "55", - "27 (49.1%)", "13 (23.6%)", "10 (18.2%)", "5 (9.1%)", "0", - "0", "0", "0", "", "55", "51.3 (8.9)", "49.4", - "33.3 - 71.9", "", "55", "49.0 (9.3)", "47.9", "24.3 - 69.2", "", - "55", "49.0 (6.7)", "48.5", "31.5 - 64.0", "", "134", "33.8 (6.6)", - "33.0", "21.0 - 50.0", "", "134", "113 (84.3%)", "21 (15.7%)", "0", - "", "134", "79 (59%)", "55 (41%)", "B: Placebo", "(N=134)", "", - "", "82", "40 (48.8%)", "16 (19.5%)", "18 (22%)", "7 (8.5%)", - "0", "1 (1.2%)", "0", "0", "", "82", "50.0 (7.8)", - "50.7", "27.9 - 68.9", "", "82", "49.6 (8.6)", "49.0", "24.4 - 68.8", - "", "82", "50.5 (7.8)", "49.9", "35.1 - 67.5", "", "", "52", - "27 (51.9%)", "12 (23.1%)", "8 (15.4%)", "4 (7.7%)", "1 (1.9%)", - "0", "0", "0", "", "52", "49.7 (9.2)", "50.8", - "30.5 - 69.8", "", "52", "51.3 (8.4)", "51.2", "34.0 - 71.1", "", - "52", "50.4 (8.2)", "50.4", "21.7 - 63.3", "", "134", "35.4 (7.9)", - "35.0", "21.0 - 62.0", "", "134", "103 (76.9%)", "31 (23.1%)", "0", - "", "134", "82 (61.2%)", "52 (38.8%)", "C: Combination", "(N=132)", - "", "", "70", "39 (55.7%)", "16 (22.9%)", "11 (15.7%)", "4 (5.7%)", - "0", "0", "0", "0", "", "70", "49.2 (7.5)", - "49.6", "29.4 - 63.8", "", "70", "48.1 (7.1)", "49.1", "26.2 - 63.4", - "", "70", "51.5 (7.8)", "50.6", "29.7 - 67.8", "", "", "62", - "34 (54.8%)", "16 (25.8%)", "10 (16.1%)", "2 (3.2%)", "0", - "0", "0", "0", "", "62", "49.6 (7.5)", "49.6", - "35.5 - 65.1", "", "62", "49.0 (7.3)", "50.3", "30.0 - 61.6", "", - "62", "50.7 (7.8)", "50.9", "30.8 - 71.4", "", "132", "35.4 (7.7)", - "35.0", "20.0 - 69.0", "", "132", "106 (80.3%)", "25 (18.9%)", "1 (0.8%)", - "", "132", "70 (53%)", "62 (47%)", "All Patients", "(N=400)", - "", "", "231", "120 (51.9%)", "50 (21.6%)", "46 (19.9%)", "14 (6.1%)", - "0", "1 (0.4%)", "0", "0", "", "231", "49.9 (7.4)", - "50.3", "27.9 - 69.9", "", "231", "49.1 (7.9)", "49.1", "24.4 - 71.1", - "", "231", "50.1 (8.2)", "49.9", "27.7 - 67.8", "", "", "169", - "88 (52.1%)", "41 (24.3%)", "28 (16.6%)", "11 (6.5%)", "1 (0.6%)", - "0", "0", "0", "", "169", "50.2 (8.5)", "49.6", - "30.5 - 71.9", "", "169", "49.7 (8.4)", "50.1", "24.3 - 71.1", - "", "169", "50.0 (7.6)", "50.1", "21.7 - 71.4", "", "400", "34.9 (7.4)", - "34.0", "20.0 - 69.0", "", "400", "322 (80.5%)", "77 (19.2%)", "1 (0.2%)", - "", "400", "231 (57.8%)", "169 (42.2%)" - ), - .Dim = c(68L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_dort01.R b/tests/testthat/test-table_dort01.R index da5bf6a1be..4ba2061a03 100644 --- a/tests/testthat/test-table_dort01.R +++ b/tests/testthat/test-table_dort01.R @@ -16,7 +16,6 @@ preproc_adtte <- function(adtte) { ), EVNTDESC = factor(EVNTDESC) ) - anl } @@ -75,28 +74,8 @@ testthat::test_that("DORT01 variant 1 is produced correctly", { ) %>% build_table(adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Responders", "Responders with subsequent event (%)", - "Earliest contributing event", "Death", "Disease Progression", - "Responders without subsequent event (%)", "Duration of response (Months)", - "Median", "95% CI", "25% and 75%-ile", "Range (censored)", "Range (event)", - "12 Months duration", "Patients remaining at risk", "Event Free Rate (%)", - "95% CI", "A: Drug X", "(N=134)", "68", "33 (48.5%)", "", "14", "19", - "35 (51.5%)", "", "23.8", "(17.9, 39.6)", "9.3, 44.3", "1.6 to 64.5", - "0.3 to 44.3", "", "28", "63.41", "(50.48, 76.34)", "B: Placebo", "(N=134)", - "73", "51 (69.9%)", "", "20", "31", "22 (30.1%)", "", "11.1", "(8.3, 14.6)", - "6.2, 20.5", "0.1 to 43.8", "0.6 to 61.9", "", "25", "43.82", "(31.28, 56.36)", - "C: Combination", "(N=132)", "62", "53 (85.5%)", "", "25", "28", "9 (14.5%)", - "", "6.6", "(4.4, 9.2)", "3.0, 15.7", "0.2 to 39.6", "0.2 to 53.8", "", - "18", "33.72", "(21.28, 46.15)" - ), - .Dim = c(18L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DORT01 variant 2 (selecting sectons) is produced correctly", { @@ -151,28 +130,8 @@ testthat::test_that("DORT01 variant 2 (selecting sectons) is produced correctly" ) %>% build_table(adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Responders", "Responders with subsequent event (%)", - "Earliest contributing event", "Death", "Disease Progression", - "Responders without subsequent event (%)", "Duration of response (Months)", - "Median", "95% CI", "25% and 75%-ile", "Range (censored)", "Range (event)", - "Unstratified Analysis", "p-value (log-rank)", "Hazard Ratio", "95% CI", - "A: Drug X", "(N=134)", "68", "33 (48.5%)", "", "14", "19", "35 (51.5%)", - "", "23.8", "(17.9, 39.6)", "9.3, 44.3", "1.6 to 64.5", "0.3 to 44.3", "", - "", "", "", "B: Placebo", "(N=134)", "73", "51 (69.9%)", "", "20", "31", - "22 (30.1%)", "", "11.1", "(8.3, 14.6)", "6.2, 20.5", "0.1 to 43.8", - "0.6 to 61.9", "", "0.0029", "1.94", "(1.24, 3.02)", "C: Combination", - "(N=132)", "62", "53 (85.5%)", "", "25", "28", "9 (14.5%)", "", "6.6", - "(4.4, 9.2)", "3.0, 15.7", "0.2 to 39.6", "0.2 to 53.8", "", "<0.0001", - "2.99", "(1.92, 4.67)" - ), - .Dim = c(18L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DORT01 variant 3 (modifying conftype and alpha level) is produced correctly", { @@ -227,28 +186,8 @@ testthat::test_that("DORT01 variant 3 (modifying conftype and alpha level) is pr ) %>% build_table(adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Responders", "Responders with subsequent event (%)", - "Earliest contributing event", "Death", "Disease Progression", - "Responders without subsequent event (%)", "Duration of response (Months)", - "Median", "90% CI", "25% and 75%-ile", "Range (censored)", "Range (event)", - "12 Months duration", "Patients remaining at risk", "Event Free Rate (%)", - "97.5% CI", "A: Drug X", "(N=134)", "68", "33 (48.5%)", "", "14", "19", - "35 (51.5%)", "", "23.8", "(17.9, 30.2)", "9.3, 44.3", "1.6 to 64.5", - "0.3 to 44.3", "", "28", "63.41", "(48.63, 78.19)", "B: Placebo", "(N=134)", - "73", "51 (69.9%)", "", "20", "31", "22 (30.1%)", "", "11.1", "(9.1, 14.0)", - "6.2, 20.5", "0.1 to 43.8", "0.6 to 61.9", "", "25", "43.82", "(29.48, 58.16)", - "C: Combination", "(N=132)", "62", "53 (85.5%)", "", "25", "28", "9 (14.5%)", - "", "6.6", "(4.4, 8.0)", "3.0, 15.7", "0.2 to 39.6", "0.2 to 53.8", "", - "18", "33.72", "(19.49, 47.94)" - ), - .Dim = c(18L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DORT01 variant 4 (modifying time point for the “xx duration”) is produced correctly", { @@ -301,26 +240,6 @@ testthat::test_that("DORT01 variant 4 (modifying time point for the “xx durati ) %>% build_table(adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Responders", "Responders with subsequent event (%)", - "Earliest contributing event", "Death", "Disease Progression", - "Responders without subsequent event (%)", "Duration of response (Months)", - "Median", "95% CI", "25% and 75%-ile", "Range (censored)", "Range (event)", - "6 Months duration", "Patients remaining at risk", "Event Free Rate (%)", - "95% CI", "A: Drug X", "(N=134)", "68", "33 (48.5%)", "", "14", "19", - "35 (51.5%)", "", "23.8", "(17.9, 39.6)", "9.3, 44.3", "1.6 to 64.5", - "0.3 to 44.3", "", "51", "83.63", "(74.78, 92.48)", "B: Placebo", "(N=134)", - "73", "51 (69.9%)", "", "20", "31", "22 (30.1%)", "", "11.1", "(8.3, 14.6)", - "6.2, 20.5", "0.1 to 43.8", "0.6 to 61.9", "", "48", "76.14", "(65.92, 86.35)", - "C: Combination", "(N=132)", "62", "53 (85.5%)", "", "25", "28", "9 (14.5%)", - "", "6.6", "(4.4, 9.2)", "3.0, 15.7", "0.2 to 39.6", "0.2 to 53.8", "", "28", - "50.57", "(37.68, 63.46)" - ), - .Dim = c(18L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_dst01.R b/tests/testthat/test-table_dst01.R index 05b4b54dfc..d818f7cf8d 100644 --- a/tests/testthat/test-table_dst01.R +++ b/tests/testthat/test-table_dst01.R @@ -79,23 +79,8 @@ testthat::test_that("DST01 default variant is produced correctly", { summarize_vars("STDDRS", .stats = "count_fraction") %>% build_table(adsl0) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Completed Study", "Discontinued Study", - "Death", "Lost To Follow-Up", "Other", "Protocol Violation", - "Withdrawal By Subject", "A: Drug X", "(N=134)", "65 (48.51%)", - "15 (11.2%)", "6 (40%)", "1 (6.7%)", "2 (13.3%)", "4 (26.7%)", - "2 (13.3%)", "B: Placebo", "(N=134)", "67 (50.00%)", "28 (20.9%)", - "5 (17.9%)", "3 (10.7%)", "6 (21.4%)", "4 (14.3%)", "10 (35.7%)", - "C: Combination", "(N=132)", "69 (52.27%)", "24 (18.2%)", "4 (16.7%)", - "8 (33.3%)", "5 (20.8%)", "4 (16.7%)", "3 (12.5%)", "All Patients", - "(N=400)", "201 (50.25%)", "67 (16.8%)", "15 (22.4%)", "12 (17.9%)", - "13 (19.4%)", "12 (17.9%)", "15 (22.4%)" - ), - .Dim = c(9L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DST01 variant with grouping of reasons is produced correctly", { @@ -113,25 +98,8 @@ testthat::test_that("DST01 variant with grouping of reasons is produced correctl build_table(adsl0) %>% prune_table() - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Received treatment", "Discontinued treatment", - "Safety", "ADVERSE EVENT", "PHYSICIAN DECISION", "Other", "LACK OF EFFICACY", - "OTHER", "PROGRESSIVE DISEASE", "A: Drug X", "(N=134)", "134 (100.00%)", - "70 (52.2%)", "21 (15.7%)", "10 (47.6%)", "11 (52.4%)", "49 (36.6%)", - "14 (28.6%)", "20 (40.8%)", "15 (30.6%)", "B: Placebo", "(N=134)", - "134 (100.00%)", "65 (48.5%)", "28 (20.9%)", "10 (35.7%)", "18 (64.3%)", - "37 (27.6%)", "14 (37.8%)", "10 (27%)", "13 (35.1%)", "C: Combination", - "(N=132)", "132 (100.00%)", "68 (51.5%)", "26 (19.7%)", "11 (42.3%)", - "15 (57.7%)", "42 (31.8%)", "10 (23.8%)", "15 (35.7%)", "17 (40.5%)", - "All Patients", "(N=400)", "400 (100.00%)", "203 (50.7%)", "75 (18.8%)", - "31 (41.3%)", "44 (58.7%)", "128 (32.0%)", "38 (29.7%)", "45 (35.2%)", - "45 (35.2%)" - ), - .Dim = c(11L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DST01 variant with adding other optional rows is produced correctly", { @@ -147,22 +115,6 @@ testthat::test_that("DST01 variant with adding other optional rows is produced c summarize_vars("STDDRS", .stats = "count_fraction") %>% build_table(adsl0) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Completed Study", "Alive: In Follow-up", - "Discontinued Study", "Death", "Lost To Follow-Up", "Other", - "Protocol Violation", "Withdrawal By Subject", "A: Drug X", "(N=134)", - "65 (48.51%)", "25 (46.30%)", "15 (11.2%)", "6 (40%)", "1 (6.7%)", - "2 (13.3%)", "4 (26.7%)", "2 (13.3%)", "B: Placebo", "(N=134)", - "67 (50.00%)", "20 (51.28%)", "28 (20.9%)", "5 (17.9%)", "3 (10.7%)", - "6 (21.4%)", "4 (14.3%)", "10 (35.7%)", "C: Combination", "(N=132)", - "69 (52.27%)", "18 (46.15%)", "24 (18.2%)", "4 (16.7%)", "8 (33.3%)", - "5 (20.8%)", "4 (16.7%)", "3 (12.5%)", "All Patients", "(N=400)", - "201 (50.25%)", "63 (47.73%)", "67 (16.8%)", "15 (22.4%)", "12 (17.9%)", - "13 (19.4%)", "12 (17.9%)", "15 (22.4%)" - ), - .Dim = c(10L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_dth01.R b/tests/testthat/test-table_dth01.R index cfbd296300..777f864a25 100644 --- a/tests/testthat/test-table_dth01.R +++ b/tests/testthat/test-table_dth01.R @@ -6,7 +6,7 @@ testthat::test_that("DTH01 variant 1 is produced correctly", { adsl <- adsl %>% df_explicit_na() - tbl1 <- basic_table() %>% + result <- basic_table() %>% split_cols_by("ARM", split_fun = add_overall_level("All Patients", first = FALSE)) %>% add_colcounts() %>% count_values( @@ -18,21 +18,8 @@ testthat::test_that("DTH01 variant 1 is produced correctly", { summarize_vars(vars = c("DTHCAT"), var_labels = c("Primary cause of death")) %>% build_table(df = adsl) - result <- to_string_matrix(tbl1) - expected <- structure( - c( - "", "", "Total number of deaths", "Primary cause of death", - "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", "A: Drug X", - "(N=134)", "25 (18.7%)", "", "25", "9 (36%)", "8 (32%)", - "8 (32%)", "B: Placebo", "(N=134)", "23 (17.2%)", "", "23", - "7 (30.4%)", "10 (43.5%)", "6 (26.1%)", "C: Combination", "(N=132)", - "22 (16.7%)", "", "22", "10 (45.5%)", "6 (27.3%)", "6 (27.3%)", - "All Patients", "(N=400)", "70 (17.5%)", "", "70", "26 (37.1%)", - "24 (34.3%)", "20 (28.6%)" - ), - .Dim = c(8L, 5L) - ) - testthat::expect_identical(result, expected) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DTH01 variant 2 is produced correctly", { @@ -88,36 +75,10 @@ testthat::test_that("DTH01 variant 2 is produced correctly", { col_info(part4) <- col_info(part3) tbl2 <- rbind(part1, part2) tbl2 <- rbind(tbl2, part3) - tbl2 <- rbind(tbl2, part4) + result <- rbind(tbl2, part4) - result <- to_string_matrix(tbl2) - expected <- structure( - c( - "", "", "Total number of deaths", "Primary cause of death", - "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", "LOST TO FOLLOW UP", "MISSING", - "Post-study reporting of death", "SUICIDE", "UNKNOWN", "Days from last drug administration", - "n", "<=30", ">30", "Primary cause by days from last study drug administration", - "<=30", "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", - ">30", "n", "ADVERSE EVENT", "OTHER", "PROGRESSIVE DISEASE", - "A: Drug X", "(N=134)", "25 (18.7%)", "", "25", "9 (36%)", - "8 (32%)", "8 (32%)", "2 (25%)", "2 (25%)", "1 (12.5%)", - "2 (25%)", "1 (12.5%)", "", "25", "14 (56%)", "11 (44%)", "", "", "14", - "4 (28.6%)", "4 (28.6%)", "6 (42.9%)", "", "11", "5 (45.5%)", "4 (36.4%)", - "2 (18.2%)", "B: Placebo", "(N=134)", "23 (17.2%)", "", "23", "7 (30.4%)", - "10 (43.5%)", "6 (26.1%)", "2 (20%)", "3 (30%)", "2 (20%)", "2 (20%)", "1 (10%)", - "", "23", "11 (47.8%)", "12 (52.2%)", "", "", "11", "2 (18.2%)", - "6 (54.5%)", "3 (27.3%)", "", "12", "5 (41.7%)", "4 (33.3%)", "3 (25%)", - "C: Combination", "(N=132)", "22 (16.7%)", "", "22", "10 (45.5%)", - "6 (27.3%)", "6 (27.3%)", "2 (33.3%)", "2 (33.3%)", "1 (16.7%)", "1 (16.7%)", "0", - "", "22", "14 (63.6%)", "8 (36.4%)", "", "", "14", "6 (42.9%)", "4 (28.6%)", "4 (28.6%)", "", "8", - "4 (50%)", "2 (25%)", "2 (25%)", "All Patients", "(N=400)", "70 (17.5%)", "", "70", "26 (37.1%)", - "24 (34.3%)", "20 (28.6%)", "6 (25%)", "7 (29.2%)", "4 (16.7%)", "5 (20.8%)", - "2 (8.3%)", "", "70", "39 (55.7%)", "31 (44.3%)", "", "", "39", - "12 (30.8%)", "14 (35.9%)", "13 (33.3%)", "", "31", "14 (45.2%)", "10 (32.3%)", "7 (22.6%)" - ), - .Dim = c(28L, 5L) - ) - testthat::expect_identical(result, expected) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DTH01 variant 3 is produced correctly", { @@ -173,25 +134,10 @@ testthat::test_that("DTH01 variant 3 is produced correctly", { # now combine tables col_info(part2) <- col_info(part1) - tbl3 <- rbind(part1, part2) + result <- rbind(part1, part2) - result <- to_string_matrix(tbl3) - expected <- structure( - c( - "", "", "Total number of deaths", "Primary cause of death", - "n", "ADVERSE EVENT", "PROGRESSIVE DISEASE", "OTHER", "Post study reporting of deaths", - "All other causes", "A: Drug X", "(N=134)", "25 (18.7%)", "", - "25", "9 (36%)", "8 (32%)", "8 (32%)", "1 (12.5%)", "7 (87.5%)", - "B: Placebo", "(N=134)", "23 (17.2%)", "", "23", "7 (30.4%)", - "6 (26.1%)", "10 (43.5%)", "2 (20.0%)", "8 (80.0%)", "C: Combination", - "(N=132)", "22 (16.7%)", "", "22", "10 (45.5%)", "6 (27.3%)", - "6 (27.3%)", "1 (16.7%)", "5 (83.3%)", "All Patients", "(N=400)", - "70 (17.5%)", "", "70", "26 (37.1%)", "20 (28.6%)", "24 (34.3%)", - "4 (16.7%)", "20 (83.3%)" - ), - .Dim = c(10L, 5L) - ) - testthat::expect_identical(result, expected) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("DTH01 variant 4 is produced correctly", { @@ -265,28 +211,8 @@ testthat::test_that("DTH01 variant 4 is produced correctly", { # now combine the tables col_info(part2) <- col_info(part1) col_info(part3) <- col_info(part2) + result <- rbind(part1, part2, part3) - tbl4 <- rbind(part1, part2, part3) - tbl4 - - result <- to_string_matrix(tbl4) - expected <- structure( - c( - "", "", "Total number of deaths", "Primary cause of death", - "n", "ADVERSE EVENT", "PROGRESSIVE DISEASE", "OTHER", "Post study reporting of deaths", - "All other causes", "LOST TO FOLLOW UP", "SUICIDE", "UNKNOWN", - "MISSING", "A: Drug X", "(N=134)", "25 (18.7%)", "", "25", "9 (36%)", - "8 (32%)", "8 (32%)", "1 (12.5%)", "7 (87.5%)", "2 (28.6%)", - "2 (28.6%)", "1 (14.3%)", "2 (28.6%)", "B: Placebo", "(N=134)", - "23 (17.2%)", "", "23", "7 (30.4%)", "6 (26.1%)", "10 (43.5%)", - "2 (20.0%)", "8 (80.0%)", "2 (25%)", "2 (25%)", "1 (12.5%)", "3 (37.5%)", - "C: Combination", "(N=132)", "22 (16.7%)", "", "22", "10 (45.5%)", - "6 (27.3%)", "6 (27.3%)", "1 (16.7%)", "5 (83.3%)", "2 (40%)", "1 (20%)", - "0", "2 (40%)", "All Patients", "(N=400)", "70 (17.5%)", "", - "70", "26 (37.1%)", "20 (28.6%)", "24 (34.3%)", "4 (16.7%)", - "20 (83.3%)", "6 (30%)", "5 (25%)", "2 (10%)", "7 (35%)" - ), - .Dim = c(14L, 5L) - ) - testthat::expect_identical(result, expected) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_egt01.R b/tests/testthat/test-table_egt01.R index 3175edfa61..d88329b0d7 100644 --- a/tests/testthat/test-table_egt01.R +++ b/tests/testthat/test-table_egt01.R @@ -1,13 +1,11 @@ -# Test the single variant for EGT01. +# Test the single variant for EGT01 + adsl <- adsl_raw adeg <- adeg_raw testthat::test_that("EGT01 default variant is produced correctly", { adeg_f <- adeg %>% - dplyr::filter( - PARAM == "Heart Rate" & - AVISIT != "SCREENING" - ) + dplyr::filter(PARAM == "Heart Rate" & AVISIT != "SCREENING") l <- basic_table() %>% split_cols_by("ARM") %>% @@ -20,57 +18,6 @@ testthat::test_that("EGT01 default variant is produced correctly", { result <- build_table(l, adeg_f) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "BASELINE", "n", "Mean (SD)", "Median", "Min - Max", - "WEEK 1 DAY 8", "n", "Mean (SD)", "Median", "Min - Max", "WEEK 2 DAY 15", - "n", "Mean (SD)", "Median", "Min - Max", "WEEK 3 DAY 22", "n", - "Mean (SD)", "Median", "Min - Max", "WEEK 4 DAY 29", "n", "Mean (SD)", - "Median", "Min - Max", "WEEK 5 DAY 36", "n", "Mean (SD)", "Median", - "Min - Max", "POST-BASELINE MINIMUM", "n", "Mean (SD)", "Median", - "Min - Max", "POST-BASELINE MAXIMUM", "n", "Mean (SD)", "Median", - "Min - Max", "A: Drug X", "Analysis Value", "", "134", "71.4 (17.9)", - "72.7", "9.1 - 106.9", "", "134", "70.2 (20.3)", "70.7", "8.5 - 127.5", - "", "134", "70.3 (19.6)", "70.9", "17.1 - 116.3", "", "134", - "68.3 (20.2)", "68.8", "13.3 - 131.7", "", "134", "70.1 (18.4)", - "69.3", "22.3 - 116.5", "", "134", "66.4 (19.7)", "65.4", "23.9 - 110.4", - "", "134", "46.2 (12.2)", "47.3", "8.5 - 85.6", "", "134", "91.7 (13.9)", - "90.0", "54.0 - 131.7", "A: Drug X", "Absolute Change from Baseline", - "", "0", "NA", "NA", "NA", "", "134", "-1.3 (26.0)", - "-2.2", "-51.0 - 89.2", "", "134", "-1.1 (26.3)", "-1.1", "-85.0 - 67.5", - "", "134", "-3.2 (28.7)", "-2.2", "-81.2 - 72.6", "", "134", - "-1.4 (26.6)", "-4.5", "-58.1 - 77.3", "", "134", "-5.0 (27.1)", - "-6.8", "-73.3 - 57.2", "", "134", "-25.2 (23.2)", "-26.1", "-85.0 - 45.9", - "", "134", "20.2 (22.8)", "16.6", "-31.1 - 89.2", "B: Placebo", - "Analysis Value", "", "134", "69.8 (20.7)", "73.4", "13.5 - 115.5", - "", "134", "69.4 (20.8)", "70.5", "16.9 - 129.1", "", "134", - "71.1 (20.6)", "72.5", "9.2 - 120.5", "", "134", "68.9 (20.6)", - "67.8", "24.0 - 130.4", "", "134", "71.6 (20.3)", "72.2", "17.5 - 129.1", - "", "134", "71.3 (18.9)", "70.9", "25.9 - 125.7", "", "134", - "47.1 (14.1)", "47.3", "9.2 - 83.0", "", "134", "93.5 (14.4)", - "91.0", "63.6 - 130.4", "B: Placebo", "Absolute Change from Baseline", - "", "0", "NA", "NA", "NA", "", "134", "-0.4 (29.7)", - "-0.5", "-68.2 - 88.4", "", "134", "1.3 (31.4)", "-0.3", "-73.1 - 81.4", - "", "134", "-0.9 (30.1)", "1.2", "-73.0 - 103.3", "", "134", "1.8 (30.3)", - "-0.9", "-64.3 - 85.3", "", "134", "1.4 (27.1)", "0.6", "-71.2 - 67.4", - "", "134", "-22.7 (26.0)", "-24.3", "-73.1 - 47.0", "", "134", "23.6 (26.5)", - "22.9", "-33.1 - 103.3", "C: Combination", "Analysis Value", - "", "132", "69.3 (20.9)", "72.0", "11.6 - 115.5", "", "132", "68.7 (18.1)", - "68.6", "16.9 - 115.6", "", "132", "69.2 (18.1)", "69.3", "29.6 - 120.5", - "", "132", "70.9 (20.3)", "70.1", "20.9 - 116.8", "", "132", - "71.0 (20.6)", "70.5", "10.4 - 117.3", "", "132", "71.3 (18.6)", - "73.3", "23.9 - 117.2", "", "132", "47.4 (12.6)", "48.2", "10.4 - 80.4", - "", "132", "92.6 (12.1)", "93.4", "65.7 - 120.5", "C: Combination", - "Absolute Change from Baseline", "", "0", "NA", "NA", "NA", - "", "132", "-0.7 (27.8)", "-0.8", "-68.2 - 67.2", "", "132", - "-0.1 (28.6)", "-1.5", "-67.7 - 66.3", "", "132", "1.5 (27.3)", - "0.1", "-64.5 - 72.5", "", "132", "1.7 (29.6)", "3.8", "-65.9 - 105.7", - "", "132", "1.9 (29.6)", "1.7", "-58.2 - 68.9", "", "132", "-21.9 (24.7)", - "-24.9", "-68.2 - 45.3", "", "132", "23.3 (23.1)", "22.1", "-28.5 - 105.7" - ), - .Dim = c(42L, 7L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_egt02.R b/tests/testthat/test-table_egt02.R index a1a73b8293..1db7b50a89 100644 --- a/tests/testthat/test-table_egt02.R +++ b/tests/testthat/test-table_egt02.R @@ -1,4 +1,5 @@ -# Tests the variants for EGT02. +# Tests the variants for EGT02 + adsl <- adsl_raw adeg <- adeg_raw @@ -23,26 +24,8 @@ testthat::test_that("(EGT02) 1. Regardless of Abnormality at Baseline", { count_abnormal("ANRIND", abnormal = list(Low = "LOW", High = "HIGH"), exclude_base_abn = FALSE) %>% build_table(df = adeg, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Parameter / Analysis Reference Range Indicator", - "Heart Rate", "Low", "High", "QT Duration", "Low", "High", "RR Duration", - "Low", "High", "A: Drug X", "(N=134)", "", "", "40/134 (29.9%)", - "39/134 (29.1%)", "", "33/134 (24.6%)", "30/134 (22.4%)", "", - "45/134 (33.6%)", "29/134 (21.6%)", "B: Placebo", "(N=134)", - "", "", "43/134 (32.1%)", "45/134 (33.6%)", "", "44/134 (32.8%)", - "42/134 (31.3%)", "", "26/134 (19.4%)", "49/134 (36.6%)", "C: Combination", - "(N=132)", "", "", "37/132 (28%)", "36/132 (27.3%)", "", "47/132 (35.6%)", - "34/132 (25.8%)", "", "38/132 (28.8%)", "27/132 (20.5%)", "All Patients", - "(N=400)", "", "", "120/400 (30%)", "120/400 (30%)", "", "124/400 (31%)", - "106/400 (26.5%)", "", "109/400 (27.3%)", "105/400 (26.2%)" - ), - .Dim = c(12L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("(EGT02) 2. Among Subjects Without Abnormality at Baseline", { @@ -64,24 +47,6 @@ testthat::test_that("(EGT02) 2. Among Subjects Without Abnormality at Baseline", count_abnormal("ANRIND", abnormal = list(Low = "LOW", High = "HIGH"), exclude_base_abn = TRUE) %>% build_table(df = adeg, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Parameter / Analysis Reference Range Indicator", - "Heart Rate", "Low", "High", "QT Duration", "Low", "High", "RR Duration", - "Low", "High", "A: Drug X", "(N=134)", "", "", "39/128 (30.5%)", - "37/127 (29.1%)", "", "29/113 (25.7%)", "30/125 (24%)", "", "45/129 (34.9%)", - "27/127 (21.3%)", "B: Placebo", "(N=134)", "", "", "42/124 (33.9%)", - "43/129 (33.3%)", "", "42/126 (33.3%)", "40/130 (30.8%)", "", - "26/123 (21.1%)", "43/122 (35.2%)", "C: Combination", "(N=132)", - "", "", "33/117 (28.2%)", "31/122 (25.4%)", "", "43/124 (34.7%)", - "30/119 (25.2%)", "", "37/126 (29.4%)", "25/125 (20%)", "All Patients", - "(N=400)", "", "", "114/369 (30.9%)", "111/378 (29.4%)", "", - "114/363 (31.4%)", "100/374 (26.7%)", "", "108/378 (28.6%)", - "95/374 (25.4%)" - ), - .Dim = c(12L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_egt03.R b/tests/testthat/test-table_egt03.R index 9188280513..4cc7215aeb 100644 --- a/tests/testthat/test-table_egt03.R +++ b/tests/testthat/test-table_egt03.R @@ -1,4 +1,5 @@ -# Tests variant 1 for EGT03. +# Tests variant 1 for EGT03 + adsl <- adsl_raw adeg <- adeg_raw @@ -35,7 +36,6 @@ testthat::test_that("EGT03 variant 1 is produced correctly", { adeg_f$BNRIND[sample(seq_len(nrow(adeg_f)), size = 5)] <- "Missing" adeg_f$ANRIND[sample(seq_len(nrow(adeg_f)), size = 5)] <- "Missing" - formatters::var_labels(adeg_f) <- adeg_labels lyt <- basic_table() %>% @@ -46,27 +46,8 @@ testthat::test_that("EGT03 variant 1 is produced correctly", { result <- build_table(lyt = lyt, df = adeg_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "C: Combination (N=132)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "LOW", "", "40", "1 (0.7%)", "36 (26.9%)", "2 (1.5%)", - "1 (0.7%)", "", "43", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "1 (0.7%)", - "", "37", "4 (3%)", "31 (23.5%)", "1 (0.8%)", "1 (0.8%)", "NORMAL", - "", "92", "5 (3.7%)", "83 (61.9%)", "4 (3%)", "0", "", "89", - "9 (6.7%)", "75 (56%)", "4 (3%)", "1 (0.7%)", "", "94", "11 (8.3%)", - "75 (56.8%)", "8 (6.1%)", "0", "HIGH", "", "0", "0", "0", "0", - "0", "", "0", "0", "0", "0", "0", "", "0", "0", "0", "0", "0", - "Missing", "", "2", "0", "1 (0.7%)", "0", "1 (0.7%)", - "", "2", "0", "2 (1.5%)", "0", "0", "", "1", "0", "0", "1 (0.8%)", "0" - ), - .Dim = c(19L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("EGT03 variant 2 is produced correctly", { @@ -106,26 +87,8 @@ testthat::test_that("EGT03 variant 2 is produced correctly", { result <- build_table(lyt = lyt, df = adeg_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "C: Combination (N=132)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "LOW", "", "40", "1 (0.7%)", "36 (26.9%)", "2 (1.5%)", - "1 (0.7%)", "", "43", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "1 (0.7%)", - "", "37", "4 (3%)", "31 (23.5%)", "1 (0.8%)", "1 (0.8%)", "NORMAL", - "", "94", "5 (3.7%)", "84 (62.7%)", "4 (3%)", "1 (0.7%)", "", - "91", "9 (6.7%)", "77 (57.5%)", "4 (3%)", "1 (0.7%)", "", "95", - "11 (8.3%)", "75 (56.8%)", "9 (6.8%)", "0", "HIGH", "", "0", - "0", "0", "0", "0", "", "0", "0", "0", "0", "0", "", "0", "0", - "0", "0", "0" - ), - .Dim = c(19L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("EGT03 variant 3 is produced correctly", { @@ -165,25 +128,8 @@ testthat::test_that("EGT03 variant 3 is produced correctly", { result <- build_table(lyt = lyt, df = adeg_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", - "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", "C: Combination (N=132)", - "n", "LOW", "NORMAL", "HIGH", "LOW", "", "39", "1 (0.7%)", "36 (26.9%)", - "2 (1.5%)", "", "42", "1 (0.7%)", "40 (29.9%)", "1 (0.7%)", "", - "36", "4 (3%)", "31 (23.5%)", "1 (0.8%)", "NORMAL", "", "93", - "5 (3.7%)", "84 (62.7%)", "4 (3%)", "", "90", "9 (6.7%)", "77 (57.5%)", - "4 (3%)", "", "95", "11 (8.3%)", "75 (56.8%)", "9 (6.8%)", "HIGH", - "", "0", "0", "0", "0", "", "0", "0", "0", "0", "", "0", "0", - "0", "0", "Missing", "", "2", "0", "1 (0.7%)", "1 (0.7%)", "", "2", - "0", "2 (1.5%)", "0", "", "1", "0", "1 (0.8%)", "0" - ), - .Dim = c(16L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("EGT03 variant 4 is produced correctly", { @@ -229,26 +175,6 @@ testthat::test_that("EGT03 variant 4 is produced correctly", { result <- build_table(lyt = lyt, df = adeg_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "A: Drug X (N=134)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "B: Placebo (N=134)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "C: Combination (N=132)", "n", "LOW", "NORMAL", "HIGH", - "Missing", "LOW", "", "0", "0", "0", "0", "0", "", "0", "0", - "0", "0", "0", "", "0", "0", "0", "0", "0", "NORMAL", "", "95", - "2 (1.5%)", "88 (65.7%)", "5 (3.7%)", "0", "", "88", "8 (6%)", - "76 (56.7%)", "3 (2.2%)", "1 (0.7%)", "", "96", "12 (9.1%)", - "79 (59.8%)", "5 (3.8%)", "0", "HIGH", "", "37", "4 (3%)", - "31 (23.1%)", "1 (0.7%)", "1 (0.7%)", "", "44", "2 (1.5%)", "39 (29.1%)", - "2 (1.5%)", "1 (0.7%)", "", "35", "3 (2.3%)", "27 (20.5%)", "4 (3%)", - "1 (0.8%)", "Missing", "", "2", "0", "1 (0.7%)", "0", "1 (0.7%)", "", - "2", "0", "2 (1.5%)", "0", "0", "", "1", "0", "0", "1 (0.8%)", - "0" - ), - .Dim = c(19L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_egt04.R b/tests/testthat/test-table_egt04.R index ddfd8e39cf..ff35d75b96 100644 --- a/tests/testthat/test-table_egt04.R +++ b/tests/testthat/test-table_egt04.R @@ -1,4 +1,5 @@ -# Tests the single variant for EGT04. +# Tests the single variant for EGT04 + adsl <- adsl_raw adeg <- adeg_raw @@ -43,22 +44,9 @@ testthat::test_that("EGT04 default variant is produced correctly", { .stats = "count_fraction", na.rm = FALSE ) + result <- build_table(l, adeg_f) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "A: Drug X (N=134)", "Normal", "Abnormal", "Missing", - "B: Placebo (N=134)", "Normal", "Abnormal", "Missing", "C: Combination (N=132)", - "Normal", "Abnormal", "Missing", "Normal", "", "20 (14.9%)", "11 (8.2%)", - "0", "", "18 (13.4%)", "3 (2.2%)", "0", "", "26 (19.7%)", - "6 (4.5%)", "1 (0.8%)", "Abnormal", "", "81 (60.4%)", "19 (14.2%)", - "1 (0.7%)", "", "81 (60.4%)", "28 (20.9%)", "2 (1.5%)", "", "69 (52.3%)", - "29 (22%)", "0", "Missing", "", "1 (0.7%)", "0", - "1 (0.7%)", "", "2 (1.5%)", "0", "0", "", "1 (0.8%)", - "0", "0" - ), - .Dim = c(13L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_egt05_qtcat.R b/tests/testthat/test-table_egt05_qtcat.R index d7ac86da70..f26b4b62ad 100644 --- a/tests/testthat/test-table_egt05_qtcat.R +++ b/tests/testthat/test-table_egt05_qtcat.R @@ -1,4 +1,5 @@ # Test the single variant for EGT05_QTCAT + adsl <- adsl_raw get_adeg <- function() { @@ -51,57 +52,7 @@ testthat::test_that("EGT05_QTCAT default variant is produced correctly", { ) %>% build_table(df = adeg, alt_counts_df = adsl) %>% prune_table() - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Visit", "BASELINE", "Value at Visit", "n", - "<=450 msec", ">450 to <=480 msec", ">480 to <= 500 msec", ">500 msec", - "WEEK 1 DAY 8", "Value at Visit", "n", "<=450 msec", ">450 to <=480 msec", - ">480 to <= 500 msec", ">500 msec", "Change from Baseline", "n", - "<=30 msec", ">30 to <=60 msec", ">60 msec", "WEEK 2 DAY 15", - "Value at Visit", "n", "<=450 msec", ">450 to <=480 msec", ">480 to <= 500 msec", - ">500 msec", "Change from Baseline", "n", "<=30 msec", ">30 to <=60 msec", - ">60 msec", "WEEK 3 DAY 22", "Value at Visit", "n", "<=450 msec", - ">450 to <=480 msec", ">480 to <= 500 msec", ">500 msec", "Change from Baseline", - "n", "<=30 msec", ">30 to <=60 msec", ">60 msec", "WEEK 4 DAY 29", - "Value at Visit", "n", "<=450 msec", ">450 to <=480 msec", ">480 to <= 500 msec", - ">500 msec", "Change from Baseline", "n", "<=30 msec", ">30 to <=60 msec", - ">60 msec", "WEEK 5 DAY 36", "Value at Visit", "n", "<=450 msec", - ">450 to <=480 msec", ">480 to <= 500 msec", ">500 msec", "Change from Baseline", - "n", "<=30 msec", ">30 to <=60 msec", ">60 msec", "A: Drug X", - "(N=134)", "", "", "", "134", "115 (85.8%)", "6 (4.5%)", "4 (3%)", - "9 (6.7%)", "", "", "134", "113 (84.3%)", "10 (7.5%)", "4 (3%)", - "7 (5.2%)", "", "134", "76 (56.7%)", "7 (5.2%)", "51 (38.1%)", - "", "", "134", "111 (82.8%)", "10 (7.5%)", "7 (5.2%)", "6 (4.5%)", - "", "134", "71 (53%)", "11 (8.2%)", "52 (38.8%)", "", "", "134", - "106 (79.1%)", "13 (9.7%)", "4 (3%)", "11 (8.2%)", "", "134", - "63 (47%)", "14 (10.4%)", "57 (42.5%)", "", "", "134", "117 (87.3%)", - "7 (5.2%)", "4 (3%)", "6 (4.5%)", "", "134", "79 (59%)", "11 (8.2%)", - "44 (32.8%)", "", "", "134", "107 (79.9%)", "16 (11.9%)", "5 (3.7%)", - "6 (4.5%)", "", "134", "72 (53.7%)", "10 (7.5%)", "52 (38.8%)", - "B: Placebo", "(N=134)", "", "", "", "134", "117 (87.3%)", "10 (7.5%)", - "3 (2.2%)", "4 (3%)", "", "", "134", "106 (79.1%)", "10 (7.5%)", - "4 (3%)", "14 (10.4%)", "", "134", "75 (56%)", "13 (9.7%)", "46 (34.3%)", - "", "", "134", "114 (85.1%)", "9 (6.7%)", "2 (1.5%)", "9 (6.7%)", - "", "134", "87 (64.9%)", "9 (6.7%)", "38 (28.4%)", "", "", "134", - "112 (83.6%)", "7 (5.2%)", "5 (3.7%)", "10 (7.5%)", "", "134", - "80 (59.7%)", "8 (6%)", "46 (34.3%)", "", "", "134", "103 (76.9%)", - "14 (10.4%)", "7 (5.2%)", "10 (7.5%)", "", "134", "80 (59.7%)", - "7 (5.2%)", "47 (35.1%)", "", "", "134", "117 (87.3%)", "5 (3.7%)", - "9 (6.7%)", "3 (2.2%)", "", "134", "82 (61.2%)", "11 (8.2%)", - "41 (30.6%)", "C: Combination", "(N=132)", "", "", "", "132", - "104 (78.8%)", "9 (6.8%)", "6 (4.5%)", "13 (9.8%)", "", "", "132", - "106 (80.3%)", "11 (8.3%)", "3 (2.3%)", "12 (9.1%)", "", "132", - "75 (56.8%)", "11 (8.3%)", "46 (34.8%)", "", "", "132", "112 (84.8%)", - "9 (6.8%)", "5 (3.8%)", "6 (4.5%)", "", "132", "89 (67.4%)", - "9 (6.8%)", "34 (25.8%)", "", "", "132", "118 (89.4%)", "3 (2.3%)", - "2 (1.5%)", "9 (6.8%)", "", "132", "81 (61.4%)", "11 (8.3%)", - "40 (30.3%)", "", "", "132", "114 (86.4%)", "6 (4.5%)", "3 (2.3%)", - "9 (6.8%)", "", "132", "79 (59.8%)", "10 (7.6%)", "43 (32.6%)", - "", "", "132", "112 (84.8%)", "13 (9.8%)", "3 (2.3%)", "4 (3%)", - "", "132", "73 (55.3%)", "11 (8.3%)", "48 (36.4%)" - ), - .Dim = c(70L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_ent.R b/tests/testthat/test-table_ent.R index b2dd0ca2d5..e447858f42 100644 --- a/tests/testthat/test-table_ent.R +++ b/tests/testthat/test-table_ent.R @@ -1,4 +1,5 @@ -# Tests all ENT variants. +# Tests all ENT variants + adsl <- adsl_raw adsl$REGION1 <- droplevels(adsl$REGION1) # nolint adsl$COUNTRY <- droplevels(adsl$COUNTRY) # nolint @@ -19,138 +20,8 @@ testthat::test_that("ENT01_IT is produced correctly", { tbl <- build_table(l, adsl) result <- prune_table(tbl, all_zero_or_na, stop_depth = 4) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Africa", "NGA", - "INV ID NGA-1", "INV ID NGA-11", "INV ID NGA-12", "INV ID NGA-17", "INV ID NGA-2", - "INV ID NGA-4", "INV ID NGA-5", "INV ID NGA-6", "Asia", - "CHN", "INV ID CHN-1", "INV ID CHN-10", "INV ID CHN-11", "INV ID CHN-12", - "INV ID CHN-13", "INV ID CHN-14", "INV ID CHN-15", "INV ID CHN-16", - "INV ID CHN-17", "INV ID CHN-18", "INV ID CHN-2", "INV ID CHN-3", "INV ID CHN-4", - "INV ID CHN-5", "INV ID CHN-6", "INV ID CHN-7", "INV ID CHN-8", - "INV ID CHN-9", "PAK", "INV ID PAK-1", "INV ID PAK-11", "INV ID PAK-12", - "INV ID PAK-13", "INV ID PAK-14", "INV ID PAK-15", "INV ID PAK-2", - "INV ID PAK-4", "INV ID PAK-5", "JPN", "INV ID JPN-1", "INV ID JPN-11", - "INV ID JPN-12", "INV ID JPN-14", "INV ID JPN-17", "INV ID JPN-18", - "INV ID JPN-2", "INV ID JPN-3", "INV ID JPN-5", "INV ID JPN-6", "Eurasia", - "RUS", "INV ID RUS-1", "INV ID RUS-11", "INV ID RUS-12", - "INV ID RUS-13", "INV ID RUS-14", "INV ID RUS-16", "INV ID RUS-18", "INV ID RUS-2", - "INV ID RUS-3", "INV ID RUS-4", "INV ID RUS-5", "INV ID RUS-6", - "INV ID RUS-7", "Europe", "GBR", "INV ID GBR-1", "INV ID GBR-11", - "INV ID GBR-13", "INV ID GBR-15", "INV ID GBR-17", "INV ID GBR-6", - "North America", "USA", "INV ID USA-1", "INV ID USA-11", "INV ID USA-12", - "INV ID USA-14", "INV ID USA-15", "INV ID USA-17", "INV ID USA-19", - "INV ID USA-2", "INV ID USA-3", "INV ID USA-4", "INV ID USA-5", "INV ID USA-6", - "INV ID USA-8", "INV ID USA-9", "CAN", "INV ID CAN-1", - "INV ID CAN-11", "INV ID CAN-14", "INV ID CAN-4", "INV ID CAN-5", "South America", - "BRA", "INV ID BRA-1", "INV ID BRA-11", "INV ID BRA-12", - "INV ID BRA-13", "INV ID BRA-14", "INV ID BRA-15", "INV ID BRA-2", "INV ID BRA-3", - "INV ID BRA-4", "INV ID BRA-5", "INV ID BRA-6", "INV ID BRA-7", - "A: Drug X", "(N=134)", "8 (6.0%)", "8 (6.0%)", "3 (2.2%)", - "1 (0.7%)", "0 (0.0%)", "2 (1.5%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "91 (67.9%)", "74 (55.2%)", - "21 (15.7%)", "0 (0.0%)", "12 (9.0%)", "4 (3.0%)", - "2 (1.5%)", "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", "4 (3.0%)", - "1 (0.7%)", "9 (6.7%)", "5 (3.7%)", "3 (2.2%)", - "4 (3.0%)", "1 (0.7%)", "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", - "12 (9.0%)", "2 (1.5%)", "4 (3.0%)", "2 (1.5%)", - "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "5 (3.7%)", "2 (1.5%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", "5 (3.7%)", - "5 (3.7%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "4 (3.0%)", "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "13 (9.7%)", - "10 (7.5%)", "1 (0.7%)", "4 (3.0%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "3 (2.2%)", "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "13 (9.7%)", - "13 (9.7%)", "4 (3.0%)", "4 (3.0%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "B: Placebo", - "(N=134)", "7 (5.2%)", "7 (5.2%)", "3 (2.2%)", - "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "94 (70.1%)", "81 (60.4%)", - "20 (14.9%)", "1 (0.7%)", "20 (14.9%)", "3 (2.2%)", "6 (4.5%)", - "2 (1.5%)", "0 (0.0%)", "3 (2.2%)", "4 (3.0%)", - "0 (0.0%)", "4 (3.0%)", "1 (0.7%)", "3 (2.2%)", "3 (2.2%)", - "3 (2.2%)", "5 (3.7%)", "1 (0.7%)", "2 (1.5%)", - "9 (6.7%)", "4 (3.0%)", "3 (2.2%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "8 (6.0%)", "8 (6.0%)", - "0 (0.0%)", "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "3 (2.2%)", "3 (2.2%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", "15 (11.2%)", - "13 (9.7%)", "4 (3.0%)", "2 (1.5%)", "2 (1.5%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "7 (5.2%)", "7 (5.2%)", - "2 (1.5%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "C: Combination", - "(N=132)", "11 (8.3%)", "11 (8.3%)", "4 (3.0%)", "3 (2.3%)", - "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "1 (0.8%)", "83 (62.9%)", "64 (48.5%)", "16 (12.1%)", - "0 (0.0%)", "16 (12.1%)", "1 (0.8%)", "0 (0.0%)", - "3 (2.3%)", "4 (3.0%)", "3 (2.3%)", "3 (2.3%)", "2 (1.5%)", - "3 (2.3%)", "5 (3.8%)", "3 (2.3%)", "4 (3.0%)", - "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", "10 (7.6%)", - "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "2 (1.5%)", "1 (0.8%)", "1 (0.8%)", - "9 (6.8%)", "1 (0.8%)", "3 (2.3%)", "1 (0.8%)", - "0 (0.0%)", "2 (1.5%)", "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", "6 (4.5%)", "6 (4.5%)", - "0 (0.0%)", "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", "2 (1.5%)", - "2 (1.5%)", "1 (0.8%)", "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "20 (15.2%)", "17 (12.9%)", - "5 (3.8%)", "3 (2.3%)", "3 (2.3%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", "1 (0.8%)", "1 (0.8%)", "1 (0.8%)", - "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "3 (2.3%)", "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", "10 (7.6%)", "10 (7.6%)", - "2 (1.5%)", "4 (3.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "0 (0.0%)", "1 (0.8%)", "All Patients", "(N=400)", - "26 (6.5%)", "26 (6.5%)", "10 (2.5%)", "6 (1.5%)", - "2 (0.5%)", "2 (0.5%)", "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "268 (67.0%)", "219 (54.8%)", "57 (14.2%)", - "1 (0.2%)", "48 (12.0%)", "8 (2.0%)", "8 (2.0%)", "9 (2.2%)", - "6 (1.5%)", "6 (1.5%)", "11 (2.8%)", "3 (0.8%)", - "16 (4.0%)", "11 (2.8%)", "9 (2.2%)", "11 (2.8%)", "4 (1.0%)", - "6 (1.5%)", "2 (0.5%)", "3 (0.8%)", "31 (7.8%)", - "10 (2.5%)", "9 (2.2%)", "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "3 (0.8%)", "2 (0.5%)", "1 (0.2%)", - "18 (4.5%)", "5 (1.2%)", "3 (0.8%)", "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", "19 (4.8%)", "19 (4.8%)", "1 (0.2%)", - "4 (1.0%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", "3 (0.8%)", - "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", "9 (2.2%)", - "9 (2.2%)", "3 (0.8%)", "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", "48 (12.0%)", "40 (10.0%)", - "10 (2.5%)", "9 (2.2%)", "6 (1.5%)", "1 (0.2%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "8 (2.0%)", "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", "30 (7.5%)", "30 (7.5%)", "8 (2.0%)", - "8 (2.0%)", "1 (0.2%)", "1 (0.2%)", "2 (0.5%)", - "1 (0.2%)", "2 (0.5%)", "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)" - ), - .Dim = c(112L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("ENT01a_IT is produced correctly", { @@ -165,131 +36,8 @@ testthat::test_that("ENT01a_IT is produced correctly", { result <- build_table(l, adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "CHN", "INV ID CHN-1", "INV ID CHN-10", - "INV ID CHN-11", "INV ID CHN-12", "INV ID CHN-13", "INV ID CHN-14", - "INV ID CHN-15", "INV ID CHN-16", "INV ID CHN-17", "INV ID CHN-18", "INV ID CHN-2", - "INV ID CHN-3", "INV ID CHN-4", "INV ID CHN-5", "INV ID CHN-6", - "INV ID CHN-7", "INV ID CHN-8", "INV ID CHN-9", "USA", "INV ID USA-1", - "INV ID USA-11", "INV ID USA-12", "INV ID USA-14", "INV ID USA-15", - "INV ID USA-17", "INV ID USA-19", "INV ID USA-2", "INV ID USA-3", "INV ID USA-4", - "INV ID USA-5", "INV ID USA-6", "INV ID USA-8", "INV ID USA-9", - "BRA", "INV ID BRA-1", "INV ID BRA-11", "INV ID BRA-12", "INV ID BRA-13", - "INV ID BRA-14", "INV ID BRA-15", "INV ID BRA-2", "INV ID BRA-3", - "INV ID BRA-4", "INV ID BRA-5", "INV ID BRA-6", "INV ID BRA-7", "PAK", - "INV ID PAK-1", "INV ID PAK-11", "INV ID PAK-12", "INV ID PAK-13", - "INV ID PAK-14", "INV ID PAK-15", "INV ID PAK-2", "INV ID PAK-4", "INV ID PAK-5", - "NGA", "INV ID NGA-1", "INV ID NGA-11", "INV ID NGA-12", - "INV ID NGA-17", "INV ID NGA-2", "INV ID NGA-4", "INV ID NGA-5", "INV ID NGA-6", - "RUS", "INV ID RUS-1", "INV ID RUS-11", "INV ID RUS-12", - "INV ID RUS-13", "INV ID RUS-14", "INV ID RUS-16", "INV ID RUS-18", "INV ID RUS-2", - "INV ID RUS-3", "INV ID RUS-4", "INV ID RUS-5", "INV ID RUS-6", - "INV ID RUS-7", "JPN", "INV ID JPN-1", "INV ID JPN-11", "INV ID JPN-12", - "INV ID JPN-14", "INV ID JPN-17", "INV ID JPN-18", "INV ID JPN-2", - "INV ID JPN-3", "INV ID JPN-5", "INV ID JPN-6", "GBR", "INV ID GBR-1", - "INV ID GBR-11", "INV ID GBR-13", "INV ID GBR-15", "INV ID GBR-17", - "INV ID GBR-6", "CAN", "INV ID CAN-1", "INV ID CAN-11", "INV ID CAN-14", - "INV ID CAN-4", "INV ID CAN-5", "A: Drug X", "(N=134)", - "74 (55.2%)", "21 (15.7%)", "0 (0.0%)", "12 (9.0%)", "4 (3.0%)", - "2 (1.5%)", "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", - "4 (3.0%)", "1 (0.7%)", "9 (6.7%)", "5 (3.7%)", "3 (2.2%)", - "4 (3.0%)", "1 (0.7%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "10 (7.5%)", "1 (0.7%)", "4 (3.0%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "13 (9.7%)", "4 (3.0%)", - "4 (3.0%)", "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "12 (9.0%)", "2 (1.5%)", "4 (3.0%)", - "2 (1.5%)", "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "8 (6.0%)", "3 (2.2%)", - "1 (0.7%)", "0 (0.0%)", "2 (1.5%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "5 (3.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "5 (3.7%)", - "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "3 (2.2%)", - "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "B: Placebo", "(N=134)", "81 (60.4%)", "20 (14.9%)", - "1 (0.7%)", "20 (14.9%)", "3 (2.2%)", "6 (4.5%)", "2 (1.5%)", - "0 (0.0%)", "3 (2.2%)", "4 (3.0%)", "0 (0.0%)", - "4 (3.0%)", "1 (0.7%)", "3 (2.2%)", "3 (2.2%)", "3 (2.2%)", - "5 (3.7%)", "1 (0.7%)", "2 (1.5%)", "13 (9.7%)", - "4 (3.0%)", "2 (1.5%)", "2 (1.5%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "7 (5.2%)", "2 (1.5%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "2 (1.5%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "9 (6.7%)", "4 (3.0%)", "3 (2.2%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "7 (5.2%)", "3 (2.2%)", "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "8 (6.0%)", "0 (0.0%)", "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "4 (3.0%)", "2 (1.5%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "3 (2.2%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", "C: Combination", "(N=132)", - "64 (48.5%)", "16 (12.1%)", "0 (0.0%)", "16 (12.1%)", - "1 (0.8%)", "0 (0.0%)", "3 (2.3%)", "4 (3.0%)", "3 (2.3%)", - "3 (2.3%)", "2 (1.5%)", "3 (2.3%)", "5 (3.8%)", - "3 (2.3%)", "4 (3.0%)", "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "17 (12.9%)", "5 (3.8%)", "3 (2.3%)", - "3 (2.3%)", "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "1 (0.8%)", "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", "10 (7.6%)", "2 (1.5%)", - "4 (3.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "1 (0.8%)", "10 (7.6%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "2 (1.5%)", "1 (0.8%)", "1 (0.8%)", "11 (8.3%)", - "4 (3.0%)", "3 (2.3%)", "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", "1 (0.8%)", "6 (4.5%)", - "0 (0.0%)", "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", "9 (6.8%)", - "1 (0.8%)", "3 (2.3%)", "1 (0.8%)", "0 (0.0%)", - "2 (1.5%)", "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "2 (1.5%)", "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", "3 (2.3%)", - "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "All Patients", "(N=400)", "219 (54.8%)", "57 (14.2%)", - "1 (0.2%)", "48 (12.0%)", "8 (2.0%)", "8 (2.0%)", - "9 (2.2%)", "6 (1.5%)", "6 (1.5%)", "11 (2.8%)", "3 (0.8%)", - "16 (4.0%)", "11 (2.8%)", "9 (2.2%)", "11 (2.8%)", - "4 (1.0%)", "6 (1.5%)", "2 (0.5%)", "3 (0.8%)", "40 (10.0%)", - "10 (2.5%)", "9 (2.2%)", "6 (1.5%)", "1 (0.2%)", - "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "30 (7.5%)", "8 (2.0%)", "8 (2.0%)", "1 (0.2%)", - "1 (0.2%)", "2 (0.5%)", "1 (0.2%)", "2 (0.5%)", - "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "31 (7.8%)", "10 (2.5%)", "9 (2.2%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", "3 (0.8%)", "2 (0.5%)", - "1 (0.2%)", "26 (6.5%)", "10 (2.5%)", "6 (1.5%)", - "2 (0.5%)", "2 (0.5%)", "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "19 (4.8%)", "1 (0.2%)", "4 (1.0%)", - "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", "3 (0.8%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", "18 (4.5%)", "5 (1.2%)", "3 (0.8%)", - "1 (0.2%)", "1 (0.2%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", "2 (0.5%)", "1 (0.2%)", "9 (2.2%)", - "3 (0.8%)", "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", "8 (2.0%)", "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "2 (0.5%)", "1 (0.2%)" - ), - .Dim = c(106L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("ENT02_IT is produced correctly", { @@ -309,293 +57,8 @@ testthat::test_that("ENT02_IT is produced correctly", { tbl <- build_table(l, adsl) result <- prune_table(tbl, all_zero_or_na, stop_depth = 4) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", - "Africa", "NGA", - "INV ID NGA-1 / Dr. NGA-1 Doe", "INV ID NGA-11 / Dr. NGA-11 Doe", - "INV ID NGA-12 / Dr. NGA-12 Doe", "INV ID NGA-17 / Dr. NGA-17 Doe", - "INV ID NGA-2 / Dr. NGA-2 Doe", "INV ID NGA-4 / Dr. NGA-4 Doe", - "INV ID NGA-5 / Dr. NGA-5 Doe", "INV ID NGA-6 / Dr. NGA-6 Doe", - "Asia", "CHN", - "INV ID CHN-1 / Dr. CHN-1 Doe", "INV ID CHN-10 / Dr. CHN-10 Doe", - "INV ID CHN-11 / Dr. CHN-11 Doe", "INV ID CHN-12 / Dr. CHN-12 Doe", - "INV ID CHN-13 / Dr. CHN-13 Doe", "INV ID CHN-14 / Dr. CHN-14 Doe", - "INV ID CHN-15 / Dr. CHN-15 Doe", "INV ID CHN-16 / Dr. CHN-16 Doe", - "INV ID CHN-17 / Dr. CHN-17 Doe", "INV ID CHN-18 / Dr. CHN-18 Doe", - "INV ID CHN-2 / Dr. CHN-2 Doe", "INV ID CHN-3 / Dr. CHN-3 Doe", - "INV ID CHN-4 / Dr. CHN-4 Doe", "INV ID CHN-5 / Dr. CHN-5 Doe", - "INV ID CHN-6 / Dr. CHN-6 Doe", "INV ID CHN-7 / Dr. CHN-7 Doe", - "INV ID CHN-8 / Dr. CHN-8 Doe", "INV ID CHN-9 / Dr. CHN-9 Doe", - "PAK", "INV ID PAK-1 / Dr. PAK-1 Doe", - "INV ID PAK-11 / Dr. PAK-11 Doe", "INV ID PAK-12 / Dr. PAK-12 Doe", - "INV ID PAK-13 / Dr. PAK-13 Doe", "INV ID PAK-14 / Dr. PAK-14 Doe", - "INV ID PAK-15 / Dr. PAK-15 Doe", "INV ID PAK-2 / Dr. PAK-2 Doe", - "INV ID PAK-4 / Dr. PAK-4 Doe", "INV ID PAK-5 / Dr. PAK-5 Doe", - "JPN", "INV ID JPN-1 / Dr. JPN-1 Doe", - "INV ID JPN-11 / Dr. JPN-11 Doe", "INV ID JPN-12 / Dr. JPN-12 Doe", - "INV ID JPN-14 / Dr. JPN-14 Doe", "INV ID JPN-17 / Dr. JPN-17 Doe", - "INV ID JPN-18 / Dr. JPN-18 Doe", "INV ID JPN-2 / Dr. JPN-2 Doe", - "INV ID JPN-3 / Dr. JPN-3 Doe", "INV ID JPN-5 / Dr. JPN-5 Doe", - "INV ID JPN-6 / Dr. JPN-6 Doe", "Eurasia", - "RUS", "INV ID RUS-1 / Dr. RUS-1 Doe", - "INV ID RUS-11 / Dr. RUS-11 Doe", "INV ID RUS-12 / Dr. RUS-12 Doe", - "INV ID RUS-13 / Dr. RUS-13 Doe", "INV ID RUS-14 / Dr. RUS-14 Doe", - "INV ID RUS-16 / Dr. RUS-16 Doe", "INV ID RUS-18 / Dr. RUS-18 Doe", - "INV ID RUS-2 / Dr. RUS-2 Doe", "INV ID RUS-3 / Dr. RUS-3 Doe", - "INV ID RUS-4 / Dr. RUS-4 Doe", "INV ID RUS-5 / Dr. RUS-5 Doe", - "INV ID RUS-6 / Dr. RUS-6 Doe", "INV ID RUS-7 / Dr. RUS-7 Doe", - "Europe", "GBR", - "INV ID GBR-1 / Dr. GBR-1 Doe", "INV ID GBR-11 / Dr. GBR-11 Doe", - "INV ID GBR-13 / Dr. GBR-13 Doe", "INV ID GBR-15 / Dr. GBR-15 Doe", - "INV ID GBR-17 / Dr. GBR-17 Doe", "INV ID GBR-6 / Dr. GBR-6 Doe", - "North America", "USA", - "INV ID USA-1 / Dr. USA-1 Doe", "INV ID USA-11 / Dr. USA-11 Doe", - "INV ID USA-12 / Dr. USA-12 Doe", "INV ID USA-14 / Dr. USA-14 Doe", - "INV ID USA-15 / Dr. USA-15 Doe", "INV ID USA-17 / Dr. USA-17 Doe", - "INV ID USA-19 / Dr. USA-19 Doe", "INV ID USA-2 / Dr. USA-2 Doe", - "INV ID USA-3 / Dr. USA-3 Doe", "INV ID USA-4 / Dr. USA-4 Doe", - "INV ID USA-5 / Dr. USA-5 Doe", "INV ID USA-6 / Dr. USA-6 Doe", - "INV ID USA-8 / Dr. USA-8 Doe", "INV ID USA-9 / Dr. USA-9 Doe", - "CAN", "INV ID CAN-1 / Dr. CAN-1 Doe", - "INV ID CAN-11 / Dr. CAN-11 Doe", "INV ID CAN-14 / Dr. CAN-14 Doe", - "INV ID CAN-4 / Dr. CAN-4 Doe", "INV ID CAN-5 / Dr. CAN-5 Doe", - "South America", "BRA", - "INV ID BRA-1 / Dr. BRA-1 Doe", "INV ID BRA-11 / Dr. BRA-11 Doe", - "INV ID BRA-12 / Dr. BRA-12 Doe", "INV ID BRA-13 / Dr. BRA-13 Doe", - "INV ID BRA-14 / Dr. BRA-14 Doe", "INV ID BRA-15 / Dr. BRA-15 Doe", - "INV ID BRA-2 / Dr. BRA-2 Doe", "INV ID BRA-3 / Dr. BRA-3 Doe", - "INV ID BRA-4 / Dr. BRA-4 Doe", "INV ID BRA-5 / Dr. BRA-5 Doe", - "INV ID BRA-6 / Dr. BRA-6 Doe", "INV ID BRA-7 / Dr. BRA-7 Doe", - "A: Drug X", "(N=134)", - "8 (6.0%)", "8 (6.0%)", - "3 (2.2%)", "1 (0.7%)", - "0 (0.0%)", "2 (1.5%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "91 (67.9%)", "74 (55.2%)", - "21 (15.7%)", "0 (0.0%)", - "12 (9.0%)", "4 (3.0%)", - "2 (1.5%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", - "4 (3.0%)", "1 (0.7%)", - "9 (6.7%)", "5 (3.7%)", - "3 (2.2%)", "4 (3.0%)", - "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "12 (9.0%)", "2 (1.5%)", - "4 (3.0%)", "2 (1.5%)", - "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "5 (3.7%)", "2 (1.5%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "5 (3.7%)", - "5 (3.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "4 (3.0%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "13 (9.7%)", "10 (7.5%)", - "1 (0.7%)", "4 (3.0%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", - "3 (2.2%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "13 (9.7%)", "13 (9.7%)", - "4 (3.0%)", "4 (3.0%)", - "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "B: Placebo", "(N=134)", - "7 (5.2%)", "7 (5.2%)", - "3 (2.2%)", "2 (1.5%)", - "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "94 (70.1%)", "81 (60.4%)", - "20 (14.9%)", "1 (0.7%)", - "20 (14.9%)", "3 (2.2%)", - "6 (4.5%)", "2 (1.5%)", - "0 (0.0%)", "3 (2.2%)", - "4 (3.0%)", "0 (0.0%)", - "4 (3.0%)", "1 (0.7%)", - "3 (2.2%)", "3 (2.2%)", - "3 (2.2%)", "5 (3.7%)", - "1 (0.7%)", "2 (1.5%)", - "9 (6.7%)", "4 (3.0%)", - "3 (2.2%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "4 (3.0%)", "2 (1.5%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "8 (6.0%)", - "8 (6.0%)", "0 (0.0%)", - "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "3 (2.2%)", "3 (2.2%)", - "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "15 (11.2%)", "13 (9.7%)", - "4 (3.0%)", "2 (1.5%)", - "2 (1.5%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "7 (5.2%)", "7 (5.2%)", - "2 (1.5%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "2 (1.5%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "C: Combination", "(N=132)", - "11 (8.3%)", "11 (8.3%)", - "4 (3.0%)", "3 (2.3%)", - "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "1 (0.8%)", - "83 (62.9%)", "64 (48.5%)", - "16 (12.1%)", "0 (0.0%)", - "16 (12.1%)", "1 (0.8%)", - "0 (0.0%)", "3 (2.3%)", - "4 (3.0%)", "3 (2.3%)", - "3 (2.3%)", "2 (1.5%)", - "3 (2.3%)", "5 (3.8%)", - "3 (2.3%)", "4 (3.0%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", - "10 (7.6%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "2 (1.5%)", - "1 (0.8%)", "1 (0.8%)", - "9 (6.8%)", "1 (0.8%)", - "3 (2.3%)", "1 (0.8%)", - "0 (0.0%)", "2 (1.5%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "6 (4.5%)", - "6 (4.5%)", "0 (0.0%)", - "2 (1.5%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", - "2 (1.5%)", "2 (1.5%)", - "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "20 (15.2%)", "17 (12.9%)", - "5 (3.8%)", "3 (2.3%)", - "3 (2.3%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", - "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", - "3 (2.3%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", - "10 (7.6%)", "10 (7.6%)", - "2 (1.5%)", "4 (3.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "1 (0.8%)", - "All Patients", "(N=400)", - "26 (6.5%)", "26 (6.5%)", - "10 (2.5%)", "6 (1.5%)", - "2 (0.5%)", "2 (0.5%)", - "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", - "268 (67.0%)", "219 (54.8%)", - "57 (14.2%)", "1 (0.2%)", - "48 (12.0%)", "8 (2.0%)", - "8 (2.0%)", "9 (2.2%)", - "6 (1.5%)", "6 (1.5%)", - "11 (2.8%)", "3 (0.8%)", - "16 (4.0%)", "11 (2.8%)", - "9 (2.2%)", "11 (2.8%)", - "4 (1.0%)", "6 (1.5%)", - "2 (0.5%)", "3 (0.8%)", - "31 (7.8%)", "10 (2.5%)", - "9 (2.2%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "3 (0.8%)", - "2 (0.5%)", "1 (0.2%)", - "18 (4.5%)", "5 (1.2%)", - "3 (0.8%)", "1 (0.2%)", - "1 (0.2%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "2 (0.5%)", - "1 (0.2%)", "19 (4.8%)", - "19 (4.8%)", "1 (0.2%)", - "4 (1.0%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "3 (0.8%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "9 (2.2%)", "9 (2.2%)", - "3 (0.8%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "48 (12.0%)", "40 (10.0%)", - "10 (2.5%)", "9 (2.2%)", - "6 (1.5%)", "1 (0.2%)", - "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "8 (2.0%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", - "30 (7.5%)", "30 (7.5%)", - "8 (2.0%)", "8 (2.0%)", - "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", - "2 (0.5%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)" - ), - .Dim = c(112L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("ENT02a_IT is produced correctly", { @@ -612,223 +75,6 @@ testthat::test_that("ENT02a_IT is produced correctly", { result <- build_table(l, adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "CHN", - "INV ID CHN-1 / Dr. CHN-1 Doe", "INV ID CHN-10 / Dr. CHN-10 Doe", - "INV ID CHN-11 / Dr. CHN-11 Doe", "INV ID CHN-12 / Dr. CHN-12 Doe", "INV ID CHN-13 / Dr. CHN-13 Doe", - "INV ID CHN-14 / Dr. CHN-14 Doe", "INV ID CHN-15 / Dr. CHN-15 Doe", - "INV ID CHN-16 / Dr. CHN-16 Doe", "INV ID CHN-17 / Dr. CHN-17 Doe", "INV ID CHN-18 / Dr. CHN-18 Doe", - "INV ID CHN-2 / Dr. CHN-2 Doe", "INV ID CHN-3 / Dr. CHN-3 Doe", - "INV ID CHN-4 / Dr. CHN-4 Doe", "INV ID CHN-5 / Dr. CHN-5 Doe", "INV ID CHN-6 / Dr. CHN-6 Doe", - "INV ID CHN-7 / Dr. CHN-7 Doe", "INV ID CHN-8 / Dr. CHN-8 Doe", - "INV ID CHN-9 / Dr. CHN-9 Doe", "USA", "INV ID USA-1 / Dr. USA-1 Doe", - "INV ID USA-11 / Dr. USA-11 Doe", "INV ID USA-12 / Dr. USA-12 Doe", - "INV ID USA-14 / Dr. USA-14 Doe", "INV ID USA-15 / Dr. USA-15 Doe", "INV ID USA-17 / Dr. USA-17 Doe", - "INV ID USA-19 / Dr. USA-19 Doe", "INV ID USA-2 / Dr. USA-2 Doe", - "INV ID USA-3 / Dr. USA-3 Doe", "INV ID USA-4 / Dr. USA-4 Doe", "INV ID USA-5 / Dr. USA-5 Doe", - "INV ID USA-6 / Dr. USA-6 Doe", "INV ID USA-8 / Dr. USA-8 Doe", - "INV ID USA-9 / Dr. USA-9 Doe", "BRA", "INV ID BRA-1 / Dr. BRA-1 Doe", - "INV ID BRA-11 / Dr. BRA-11 Doe", "INV ID BRA-12 / Dr. BRA-12 Doe", - "INV ID BRA-13 / Dr. BRA-13 Doe", "INV ID BRA-14 / Dr. BRA-14 Doe", "INV ID BRA-15 / Dr. BRA-15 Doe", - "INV ID BRA-2 / Dr. BRA-2 Doe", "INV ID BRA-3 / Dr. BRA-3 Doe", - "INV ID BRA-4 / Dr. BRA-4 Doe", "INV ID BRA-5 / Dr. BRA-5 Doe", "INV ID BRA-6 / Dr. BRA-6 Doe", - "INV ID BRA-7 / Dr. BRA-7 Doe", "PAK", - "INV ID PAK-1 / Dr. PAK-1 Doe", "INV ID PAK-11 / Dr. PAK-11 Doe", "INV ID PAK-12 / Dr. PAK-12 Doe", - "INV ID PAK-13 / Dr. PAK-13 Doe", "INV ID PAK-14 / Dr. PAK-14 Doe", - "INV ID PAK-15 / Dr. PAK-15 Doe", "INV ID PAK-2 / Dr. PAK-2 Doe", "INV ID PAK-4 / Dr. PAK-4 Doe", - "INV ID PAK-5 / Dr. PAK-5 Doe", "NGA", - "INV ID NGA-1 / Dr. NGA-1 Doe", "INV ID NGA-11 / Dr. NGA-11 Doe", "INV ID NGA-12 / Dr. NGA-12 Doe", - "INV ID NGA-17 / Dr. NGA-17 Doe", "INV ID NGA-2 / Dr. NGA-2 Doe", - "INV ID NGA-4 / Dr. NGA-4 Doe", "INV ID NGA-5 / Dr. NGA-5 Doe", "INV ID NGA-6 / Dr. NGA-6 Doe", - "RUS", "INV ID RUS-1 / Dr. RUS-1 Doe", - "INV ID RUS-11 / Dr. RUS-11 Doe", "INV ID RUS-12 / Dr. RUS-12 Doe", "INV ID RUS-13 / Dr. RUS-13 Doe", - "INV ID RUS-14 / Dr. RUS-14 Doe", "INV ID RUS-16 / Dr. RUS-16 Doe", - "INV ID RUS-18 / Dr. RUS-18 Doe", "INV ID RUS-2 / Dr. RUS-2 Doe", "INV ID RUS-3 / Dr. RUS-3 Doe", - "INV ID RUS-4 / Dr. RUS-4 Doe", "INV ID RUS-5 / Dr. RUS-5 Doe", - "INV ID RUS-6 / Dr. RUS-6 Doe", "INV ID RUS-7 / Dr. RUS-7 Doe", "JPN", - "INV ID JPN-1 / Dr. JPN-1 Doe", "INV ID JPN-11 / Dr. JPN-11 Doe", - "INV ID JPN-12 / Dr. JPN-12 Doe", "INV ID JPN-14 / Dr. JPN-14 Doe", "INV ID JPN-17 / Dr. JPN-17 Doe", - "INV ID JPN-18 / Dr. JPN-18 Doe", "INV ID JPN-2 / Dr. JPN-2 Doe", - "INV ID JPN-3 / Dr. JPN-3 Doe", "INV ID JPN-5 / Dr. JPN-5 Doe", "INV ID JPN-6 / Dr. JPN-6 Doe", - "GBR", "INV ID GBR-1 / Dr. GBR-1 Doe", - "INV ID GBR-11 / Dr. GBR-11 Doe", "INV ID GBR-13 / Dr. GBR-13 Doe", "INV ID GBR-15 / Dr. GBR-15 Doe", - "INV ID GBR-17 / Dr. GBR-17 Doe", "INV ID GBR-6 / Dr. GBR-6 Doe", - "CAN", "INV ID CAN-1 / Dr. CAN-1 Doe", "INV ID CAN-11 / Dr. CAN-11 Doe", - "INV ID CAN-14 / Dr. CAN-14 Doe", "INV ID CAN-4 / Dr. CAN-4 Doe", - "INV ID CAN-5 / Dr. CAN-5 Doe", "A: Drug X", "(N=134)", - "74 (55.2%)", "21 (15.7%)", - "0 (0.0%)", "12 (9.0%)", "4 (3.0%)", - "2 (1.5%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", "4 (3.0%)", - "1 (0.7%)", "9 (6.7%)", - "5 (3.7%)", "3 (2.2%)", "4 (3.0%)", - "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "10 (7.5%)", - "1 (0.7%)", "4 (3.0%)", - "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "13 (9.7%)", - "4 (3.0%)", "4 (3.0%)", - "0 (0.0%)", "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "12 (9.0%)", "2 (1.5%)", "4 (3.0%)", - "2 (1.5%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "8 (6.0%)", "3 (2.2%)", "1 (0.7%)", - "0 (0.0%)", "2 (1.5%)", - "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "5 (3.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "5 (3.7%)", "2 (1.5%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "3 (2.2%)", "1 (0.7%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "B: Placebo", - "(N=134)", "81 (60.4%)", - "20 (14.9%)", "1 (0.7%)", "20 (14.9%)", - "3 (2.2%)", "6 (4.5%)", - "2 (1.5%)", "0 (0.0%)", "3 (2.2%)", - "4 (3.0%)", "0 (0.0%)", - "4 (3.0%)", "1 (0.7%)", "3 (2.2%)", - "3 (2.2%)", "3 (2.2%)", - "5 (3.7%)", "1 (0.7%)", "2 (1.5%)", - "13 (9.7%)", "4 (3.0%)", - "2 (1.5%)", "2 (1.5%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "7 (5.2%)", "2 (1.5%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "9 (6.7%)", "4 (3.0%)", - "3 (2.2%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "7 (5.2%)", "3 (2.2%)", - "2 (1.5%)", "1 (0.7%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "8 (6.0%)", "0 (0.0%)", "2 (1.5%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "2 (1.5%)", "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "4 (3.0%)", - "2 (1.5%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "3 (2.2%)", "0 (0.0%)", "1 (0.7%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.7%)", "1 (0.7%)", "2 (1.5%)", - "1 (0.7%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.7%)", "0 (0.0%)", - "C: Combination", "(N=132)", - "64 (48.5%)", "16 (12.1%)", "0 (0.0%)", - "16 (12.1%)", "1 (0.8%)", - "0 (0.0%)", "3 (2.3%)", "4 (3.0%)", - "3 (2.3%)", "3 (2.3%)", - "2 (1.5%)", "3 (2.3%)", "5 (3.8%)", - "3 (2.3%)", "4 (3.0%)", - "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "17 (12.9%)", - "5 (3.8%)", "3 (2.3%)", "3 (2.3%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "1 (0.8%)", "1 (0.8%)", - "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "10 (7.6%)", - "2 (1.5%)", "4 (3.0%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", - "0 (0.0%)", "1 (0.8%)", "10 (7.6%)", - "4 (3.0%)", "2 (1.5%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "0 (0.0%)", "2 (1.5%)", - "1 (0.8%)", "1 (0.8%)", "11 (8.3%)", - "4 (3.0%)", "3 (2.3%)", - "1 (0.8%)", "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", - "1 (0.8%)", "6 (4.5%)", "0 (0.0%)", - "2 (1.5%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", - "1 (0.8%)", "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "1 (0.8%)", - "9 (6.8%)", "1 (0.8%)", "3 (2.3%)", - "1 (0.8%)", "0 (0.0%)", - "2 (1.5%)", "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "1 (0.8%)", - "0 (0.0%)", "2 (1.5%)", "1 (0.8%)", - "1 (0.8%)", "0 (0.0%)", - "0 (0.0%)", "0 (0.0%)", "0 (0.0%)", - "3 (2.3%)", "0 (0.0%)", - "1 (0.8%)", "0 (0.0%)", "1 (0.8%)", - "1 (0.8%)", "All Patients", - "(N=400)", "219 (54.8%)", "57 (14.2%)", - "1 (0.2%)", "48 (12.0%)", - "8 (2.0%)", "8 (2.0%)", "9 (2.2%)", - "6 (1.5%)", "6 (1.5%)", - "11 (2.8%)", "3 (0.8%)", "16 (4.0%)", - "11 (2.8%)", "9 (2.2%)", - "11 (2.8%)", "4 (1.0%)", "6 (1.5%)", - "2 (0.5%)", "3 (0.8%)", - "40 (10.0%)", "10 (2.5%)", "9 (2.2%)", - "6 (1.5%)", "1 (0.2%)", - "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "2 (0.5%)", - "2 (0.5%)", "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "30 (7.5%)", "8 (2.0%)", "8 (2.0%)", - "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", "2 (0.5%)", - "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "31 (7.8%)", "10 (2.5%)", - "9 (2.2%)", "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", - "3 (0.8%)", "2 (0.5%)", "1 (0.2%)", - "26 (6.5%)", "10 (2.5%)", - "6 (1.5%)", "2 (0.5%)", "2 (0.5%)", - "2 (0.5%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", "19 (4.8%)", - "1 (0.2%)", "4 (1.0%)", - "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", "3 (0.8%)", - "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "18 (4.5%)", "5 (1.2%)", - "3 (0.8%)", "1 (0.2%)", - "1 (0.2%)", "2 (0.5%)", "1 (0.2%)", - "1 (0.2%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)", "9 (2.2%)", - "3 (0.8%)", "2 (0.5%)", - "1 (0.2%)", "1 (0.2%)", "1 (0.2%)", - "1 (0.2%)", "8 (2.0%)", - "2 (0.5%)", "2 (0.5%)", "1 (0.2%)", - "2 (0.5%)", "1 (0.2%)" - ), - .Dim = c(106L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_ext01.R b/tests/testthat/test-table_ext01.R index b462aaadc0..beb7abd1f8 100644 --- a/tests/testthat/test-table_ext01.R +++ b/tests/testthat/test-table_ext01.R @@ -1,4 +1,5 @@ # Tests all variants of EXT01 + adsl <- adsl_raw adex <- adex_raw @@ -53,26 +54,8 @@ testthat::test_that("EXT01 default variant with numeric parameters is produced c summarize_vars(vars = "AVAL") %>% build_table(adex, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Total dose administered", "n", "Mean (SD)", "Median", "Min - Max", - "Total number of doses administered", "n", "Mean (SD)", "Median", "Min - Max", - "Treatment duration (days)", "n", "Mean (SD)", "Median", "Min - Max", - "Total number of missed doses during study", "n", "Mean (SD)", "Median", "Min - Max", - "A: Drug X", "(N=134)", "", "75", "6675.2 (1110.9)", "6720.0", "4800.0 - 9360.0", - "", "75", "7.0 (0.0)", "7.0", "7.0 - 7.0", "", "75", "74.3 (41.6)", "77.0", "5.0 - 149.0", - "", "75", "10.5 (5.9)", "10.0", "0.0 - 20.0", - "B: Placebo", "(N=134)", "", "67", "6505.1 (1249.3)", "6480.0", "4080.0 - 9360.0", - "", "67", "7.0 (0.0)", "7.0", "7.0 - 7.0", "", "67", "79.0 (43.1)", "80.0", "2.0 - 150.0", - "", "67", "10.0 (6.1)", "11.0", "0.0 - 19.0", - "C: Combination", "(N=132)", "", "75", "6982.4 (1272.5)", "7200.0", "4320.0 - 9360.0", - "", "75", "7.0 (0.0)", "7.0", "7.0 - 7.0", "", "75", "74.2 (39.5)", "78.0", "1.0 - 147.0", - "", "75", "9.5 (5.5)", "9.0", "0.0 - 20.0" - ), - .Dim = c(22L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("EXT01 variant: with both numeric and categorical parameters", { @@ -160,29 +143,8 @@ testthat::test_that("EXT01 variant: with both numeric and categorical parameters ) %>% build_table(anl, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Treatment duration (days)", "n", "Mean (SD)", "Median", "Min - Max", - "Treatment duration (days)", "n", "0 - 30", "31 - 60", "61 - 90", ">= 91", - "Total dose administered", "n", "Mean (SD)", "Median", "Min - Max", - "Total number of doses administered", "n", "Mean (SD)", "Median", "Min - Max", - "A: Drug X", "(N=134)", "", "75", "74.3 (41.6)", "77.0", "5.0 - 149.0", - "", "75", "12 (16%)", "18 (24%)", "19 (25.3%)", "26 (34.7%)", - "", "75", "6675.2 (1110.9)", "6720.0", "4800.0 - 9360.0", - "", "75", "7.0 (0.0)", "7.0", "7.0 - 7.0", - "B: Placebo", "(N=134)", "", "67", "79.0 (43.1)", "80.0", "2.0 - 150.0", - "", "67", "12 (17.9%)", "12 (17.9%)", "15 (22.4%)", "28 (41.8%)", - "", "67", "6505.1 (1249.3)", "6480.0", "4080.0 - 9360.0", - "", "67", "7.0 (0.0)", "7.0", "7.0 - 7.0", - "C: Combination", "(N=132)", "", "75", "74.2 (39.5)", "78.0", "1.0 - 147.0", - "", "75", "15 (20%)", "14 (18.7%)", "18 (24%)", "28 (37.3%)", - "", "75", "6982.4 (1272.5)", "7200.0", "4320.0 - 9360.0", - "", "75", "7.0 (0.0)", "7.0", "7.0 - 7.0" - ), - .Dim = c(23L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("EXT01 variant: with user specified categories for missed doses", { @@ -275,31 +237,6 @@ testthat::test_that("EXT01 variant: with user specified categories for missed do ) %>% build_table(anl, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Treatment duration (days)", "n", "Mean (SD)", - "Median", "Min - Max", "Treatment duration (days)", "n", "0 - 30", - "31 - 60", "61 - 90", ">= 91", "Total dose administered", "n", - "Mean (SD)", "Median", "Min - Max", "Total number of doses administered", - "n", "Mean (SD)", "Median", "Min - Max", "Missed Doses", "n", - "At least 1 missed dose", "At least 5 missed doses", "At least 10 missed doses", - "At least 15 missed doses", "A: Drug X", "(N=134)", "", "75", - "74.3 (41.6)", "77.0", "5.0 - 149.0", "", "75", "12 (16%)", "18 (24%)", - "19 (25.3%)", "26 (34.7%)", "", "75", "6675.2 (1110.9)", "6720.0", - "4800.0 - 9360.0", "", "75", "7.0 (0.0)", "7.0", "7.0 - 7.0", "", "75", "74 (55.2%)", - "59 (44%)", "41 (30.6%)", "26 (19.4%)", "B: Placebo", "(N=134)", - "", "67", "79.0 (43.1)", "80.0", "2.0 - 150.0", "", "67", "12 (17.9%)", - "12 (17.9%)", "15 (22.4%)", "28 (41.8%)", "", "67", "6505.1 (1249.3)", - "6480.0", "4080.0 - 9360.0", "", "67", "7.0 (0.0)", "7.0", "7.0 - 7.0", "", "67", - "63 (47%)", "49 (36.6%)", "38 (28.4%)", "21 (15.7%)", "C: Combination", - "(N=132)", "", "75", "74.2 (39.5)", "78.0", "1.0 - 147.0", "", "75", - "15 (20%)", "14 (18.7%)", "18 (24%)", "28 (37.3%)", "", "75", - "6982.4 (1272.5)", "7200.0", "4320.0 - 9360.0", "", "75", "7.0 (0.0)", - "7.0", "7.0 - 7.0", "", "75", "73 (55.3%)", "59 (44.7%)", "37 (28%)", - "16 (12.1%)" - ), - .Dim = c(29L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_fstg02.R b/tests/testthat/test-table_fstg02.R index cffb241ebf..633a8bb0a7 100644 --- a/tests/testthat/test-table_fstg02.R +++ b/tests/testthat/test-table_fstg02.R @@ -39,25 +39,8 @@ testthat::test_that("FSTG02 table variant 1 (Subgroup Analysis of Survival Durat time_unit = anl1$AVALU[1] ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", - "F", "M", "Categorical Level Biomarker 2", "LOW", "MEDIUM", "HIGH", - " ", "Total n", "268", "", "161", "107", "", "95", "93", "80", - "B: Placebo", "n", "134", "", "82", "52", "", "45", "56", "33", - "B: Placebo", "Median (Months)", "27.5", "", "28.0", "17.3", "", - "24.7", "23.7", "27.9", "A: Drug X", "n", "134", "", "79", "55", - "", "50", "37", "47", "A: Drug X", "Median (Months)", "41.4", - "", "41.9", "27.9", "", "38.1", "41.7", "35.2", " ", "Hazard Ratio", - "0.72", "", "0.70", "0.78", "", "0.71", "0.57", "0.98", " ", - "95% Wald CI", "(0.53, 0.98)", "", "(0.46, 1.05)", "(0.49, 1.26)", - "", "(0.42, 1.17)", "(0.32, 1.01)", "(0.56, 1.72)" - ), - .Dim = c(10L, 8L) - ) - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Add plot. g_forest( @@ -92,26 +75,9 @@ testthat::test_that("FSTG02 table variant 2 (specifying class variables and opti vars = c("n_tot", "n", "median", "hr", "ci"), time_unit = anl2$AVALU[1] ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", - "M", "F", "Stratification Factor 1", "C", "B", "A", " ", "Total n", - "268", "", "107", "161", "", "94", "92", "82", "Placebo", "n", - "134", "", "52", "82", "", "45", "45", "44", "Placebo", "Median (Months)", - "27.5", "", "17.3", "28.0", "", "16.3", "27.9", "35.7", "Drug X", - "n", "134", "", "55", "79", "", "49", "47", "38", "Drug X", "Median (Months)", - "41.4", "", "27.9", "41.9", "", "54.7", "32.4", "35.2", " ", - "Hazard Ratio", "0.72", "", "0.78", "0.70", "", "0.53", "0.87", - "0.86", " ", "95% Wald CI", "(0.53, 0.98)", "", "(0.49, 1.26)", - "(0.46, 1.05)", "", "(0.31, 0.90)", "(0.53, 1.45)", "(0.48, 1.53)" - ), - .Dim = c(10L, 8L) - ) - # expected_matrix - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Add plot. g_forest( @@ -135,20 +101,8 @@ testthat::test_that("FSTG02 table variant 3 (selecting columns and changing the vars = c("n_tot", "hr", "ci") ) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", - "F", "M", "Categorical Level Biomarker 2", "LOW", "MEDIUM", "HIGH", - " ", "Total n", "268", "", "161", "107", "", "95", "93", "80", - " ", "Hazard Ratio", "0.72", "", "0.70", "0.78", "", "0.71", - "0.57", "0.98", " ", "90% Wald CI", "(0.55, 0.93)", "", "(0.50, 0.98)", - "(0.53, 1.17)", "", "(0.46, 1.08)", "(0.36, 0.92)", "(0.61, 1.57)" - ), - .Dim = c(10L, 4L) - ) - - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Add plot. g_forest( @@ -177,25 +131,8 @@ testthat::test_that("FSTG02 table variant 4 (fixed symbol size) is produced corr time_unit = anl4$AVALU[1] ) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", - "F", "M", "Categorical Level Biomarker 2", "LOW", "MEDIUM", "HIGH", - " ", "Total n", "268", "", "161", "107", "", "95", "93", "80", - "B: Placebo", "n", "134", "", "82", "52", "", "45", "56", "33", - "B: Placebo", "Median (Months)", "27.5", "", "28.0", "17.3", "", - "24.7", "23.7", "27.9", "A: Drug X", "n", "134", "", "79", "55", - "", "50", "37", "47", "A: Drug X", "Median (Months)", "41.4", - "", "41.9", "27.9", "", "38.1", "41.7", "35.2", " ", "Hazard Ratio", - "0.72", "", "0.70", "0.78", "", "0.71", "0.57", "0.98", " ", - "95% Wald CI", "(0.53, 0.98)", "", "(0.46, 1.05)", "(0.49, 1.26)", - "", "(0.42, 1.17)", "(0.32, 1.01)", "(0.56, 1.72)" - ), - .Dim = c(10L, 8L) - ) - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) # Add plot. g_forest( diff --git a/tests/testthat/test-table_lbt01.R b/tests/testthat/test-table_lbt01.R index 253c772be6..716976709b 100644 --- a/tests/testthat/test-table_lbt01.R +++ b/tests/testthat/test-table_lbt01.R @@ -1,4 +1,5 @@ -# Test the single variant for LBT01. +# Test the single variant for LBT01 + adsl <- adsl_raw adlb <- adlb_raw @@ -20,43 +21,7 @@ testthat::test_that("LBT01 default variant is produced correctly", { summarize_colvars() result <- build_table(l, adlb_f) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "BASELINE", "n", "Mean (SD)", "Median", "Min - Max", "WEEK 1 DAY 8", - "n", "Mean (SD)", "Median", "Min - Max", "WEEK 2 DAY 15", "n", "Mean (SD)", - "Median", "Min - Max", "WEEK 3 DAY 22", "n", "Mean (SD)", "Median", - "Min - Max", "WEEK 4 DAY 29", "n", "Mean (SD)", "Median", "Min - Max", - "WEEK 5 DAY 36", "n", "Mean (SD)", "Median", "Min - Max", "A: Drug X", - "Analysis Value", "", "134", "19.8 (4.2)", "19.8", "7.0 - 30.4", "", "134", - "19.3 (4.0)", "19.2", "8.9 - 27.3", "", "134", "19.7 (4.2)", "19.2", - "7.2 - 30.5", "", "134", "20.1 (3.8)", "20.0", "11.5 - 29.5", "", "134", - "20.4 (4.6)", "19.8", "9.9 - 34.5", "", "134", "20.4 (3.9)", "20.7", - "10.9 - 30.2", "A: Drug X", "Absolute Change from Baseline", "", "134", - "0.0 (0.0)", "0.0", "0.0 - 0.0", "", "134", "-0.5 (5.9)", "-0.5", - "-12.5 - 19.7", "", "134", "-0.1 (6.0)", "0.0", "-13.2 - 17.2", "", "134", - "0.3 (5.8)", "0.5", "-16.0 - 16.3", "", "134", "0.6 (6.5)", "0.4", - "-17.0 - 18.8", "", "134", "0.6 (6.1)", "0.9", "-16.0 - 16.1", "B: Placebo", - "Analysis Value", "", "134", "20.2 (4.2)", "20.1", "8.1 - 34.6", "", "0", - "NA", "NA", "NA", "", "134", "20.1 (4.3)", "20.0", "7.2 - 30.5", - "", "134", "19.8 (3.9)", "19.9", "11.9 - 28.2", "", "134", "19.6 (4.3)", - "19.2", "11.5 - 32.0", "", "134", "19.9 (4.2)", "20.1", "10.3 - 29.1", - "B: Placebo", "Absolute Change from Baseline", "", "134", "0.0 (0.0)", - "0.0", "0.0 - 0.0", "", "0", "NA", "NA", "NA", "", "134", - "-0.0 (6.3)", "-0.4", "-18.4 - 14.4", "", "134", "-0.3 (5.6)", "-0.2", - "-18.5 - 15.0", "", "134", "-0.5 (6.3)", "-1.2", "-16.6 - 17.2", "", "134", - "-0.3 (6.3)", "0.7", "-19.0 - 12.6", "C: Combination", "Analysis Value", - "", "132", "20.5 (3.9)", "20.4", "8.8 - 28.7", "", "132", "20.6 (3.9)", - "20.4", "9.9 - 30.7", "", "132", "19.2 (3.6)", "19.6", "8.1 - 26.7", "", - "132", "19.4 (3.9)", "18.8", "10.2 - 28.5", "", "132", "19.8 (4.0)", "19.9", - "7.8 - 29.3", "", "132", "20.0 (4.2)", "20.5", "7.4 - 27.8", "C: Combination", - "Absolute Change from Baseline", "", "132", "0.0 (0.0)", "0.0", "0.0 - 0.0", - "", "132", "0.1 (5.5)", "0.0", "-13.7 - 15.5", "", "132", "-1.2 (5.5)", - "-0.5", "-14.3 - 15.6", "", "132", "-1.0 (5.6)", "-1.1", "-12.3 - 11.1", - "", "132", "-0.6 (5.3)", "-0.6", "-12.1 - 15.3", "", "132", "-0.5 (5.6)", - "-1.0", "-15.6 - 16.6" - ), - .Dim = c(32L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt02.R b/tests/testthat/test-table_lbt02.R index bfc080c9c5..f9c7d99a9d 100644 --- a/tests/testthat/test-table_lbt02.R +++ b/tests/testthat/test-table_lbt02.R @@ -1,4 +1,5 @@ -# Tests the single variant for LBT02. +# Tests the single variant for LBT02 + adsl <- adsl_raw adlb <- adlb_raw @@ -13,29 +14,7 @@ testthat::test_that("LBT02 default variant is produced correctly", { summarize_vars(vars = "AVAL") result <- build_table(l, df = adlb, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "BASELINE", "n", "Mean (SD)", "Median", "Min - Max", "WEEK 1 DAY 8", - "n", "Mean (SD)", "Median", "Min - Max", "WEEK 2 DAY 15", "n", "Mean (SD)", - "Median", "Min - Max", "WEEK 3 DAY 22", "n", "Mean (SD)", "Median", "Min - Max", - "WEEK 4 DAY 29", "n", "Mean (SD)", "Median", "Min - Max", "WEEK 5 DAY 36", - "n", "Mean (SD)", "Median", "Min - Max", "A: Drug X", "(N=134)", "", "134", - "19.8 (4.2)", "19.8", "7.0 - 30.4", "", "134", "19.3 (4.0)", "19.2", - "8.9 - 27.3", "", "134", "19.7 (4.2)", "19.2", "7.2 - 30.5", "", "134", - "20.1 (3.8)", "20.0", "11.5 - 29.5", "", "134", "20.4 (4.6)", "19.8", - "9.9 - 34.5", "", "134", "20.4 (3.9)", "20.7", "10.9 - 30.2", "B: Placebo", - "(N=134)", "", "134", "20.2 (4.2)", "20.1", "8.1 - 34.6", "", "134", - "20.2 (4.0)", "20.1", "5.8 - 28.8", "", "134", "20.1 (4.3)", "20.0", - "7.2 - 30.5", "", "134", "19.8 (3.9)", "19.9", "11.9 - 28.2", "", "134", - "19.6 (4.3)", "19.2", "11.5 - 32.0", "", "134", "19.9 (4.2)", "20.1", - "10.3 - 29.1", "C: Combination", "(N=132)", "", "132", "20.5 (3.9)", "20.4", - "8.8 - 28.7", "", "132", "20.6 (3.9)", "20.4", "9.9 - 30.7", "", "132", - "19.2 (3.6)", "19.6", "8.1 - 26.7", "", "132", "19.4 (3.9)", "18.8", - "10.2 - 28.5", "", "132", "19.8 (4.0)", "19.9", "7.8 - 29.3", "", "132", - "20.0 (4.2)", "20.5", "7.4 - 27.8" - ), - .Dim = c(32L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt03.R b/tests/testthat/test-table_lbt03.R index 779f60e0b1..dc94cb4aa2 100644 --- a/tests/testthat/test-table_lbt03.R +++ b/tests/testthat/test-table_lbt03.R @@ -1,4 +1,5 @@ -# Tests the single variant for LBT03. +# Tests the single variant for LBT03 + adsl <- adsl_raw adlb <- adlb_raw @@ -24,30 +25,6 @@ testthat::test_that("LBT03 default variant is produced correctly", { alt_counts_df = adsl ) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "BASELINE", "n", "Mean (SD)", "Median", "Min - Max", "WEEK 1 DAY 8", - "n", "Mean (SD)", "Median", "Min - Max", "WEEK 2 DAY 15", "n", "Mean (SD)", - "Median", "Min - Max", "WEEK 3 DAY 22", "n", "Mean (SD)", "Median", - "Min - Max", "WEEK 4 DAY 29", "n", "Mean (SD)", "Median", "Min - Max", - "WEEK 5 DAY 36", "n", "Mean (SD)", "Median", "Min - Max", "A: Drug X", - "(N=134)", "", "134", "19.79 (4.16)", "19.79", "6.99 - 30.43", "", "134", - "-0.48 (5.85)", "-0.51", "-12.52 - 19.70", "", "134", "-0.08 (6.00)", - "0.04", "-13.15 - 17.17", "", "134", "0.34 (5.76)", "0.45", "-16.04 - 16.26", - "", "134", "0.57 (6.51)", "0.35", "-17.00 - 18.79", "", "134", "0.63 (6.05)", - "0.93", "-16.03 - 16.09", "B: Placebo", "(N=134)", "", "134", "20.15 (4.17)", - "20.08", "8.11 - 34.56", "", "134", "0.07 (6.04)", "-0.72", "-12.29 - 17.41", - "", "134", "-0.03 (6.26)", "-0.37", "-18.37 - 14.39", "", "134", - "-0.32 (5.60)", "-0.18", "-18.52 - 15.00", "", "134", "-0.52 (6.29)", - "-1.19", "-16.58 - 17.23", "", "134", "-0.29 (6.31)", "0.73", "-19.04 - 12.64", - "C: Combination", "(N=132)", "", "132", "20.45 (3.91)", "20.39", - "8.82 - 28.72", "", "132", "0.10 (5.46)", "0.03", "-13.69 - 15.54", "", - "132", "-1.20 (5.49)", "-0.48", "-14.28 - 15.65", "", "132", "-1.02 (5.55)", - "-1.07", "-12.33 - 11.10", "", "132", "-0.63 (5.31)", "-0.65", - "-12.13 - 15.30", "", "132", "-0.46 (5.57)", "-0.99", "-15.62 - 16.61" - ), - .Dim = c(32L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt04.R b/tests/testthat/test-table_lbt04.R index 1acb86fda0..04c2eab213 100644 --- a/tests/testthat/test-table_lbt04.R +++ b/tests/testthat/test-table_lbt04.R @@ -1,4 +1,5 @@ -# Tests all variants of LBT04. +# Tests all variants of LBT04 + adsl <- adsl_raw adlb <- adlb_raw @@ -20,21 +21,6 @@ testthat::test_that("LBT04 default variant is produced correctly", { ) %>% build_table(adlb, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "CHEMISTRY", "Alanine Aminotransferase Measurement", - "Low", "High", "C-Reactive Protein Measurement", "Low", "High", - "IMMUNOLOGY", "Immunoglobulin A Measurement", "Low", "High", - "A: Drug X", "(N=134)", "", "", "50/124 (40.3%)", "49/121 (40.5%)", - "", "55/122 (45.1%)", "55/115 (47.8%)", "", "", "51/120 (42.5%)", - "58/119 (48.7%)", "B: Placebo", "(N=134)", "", "", "46/122 (37.7%)", - "48/118 (40.7%)", "", "44/125 (35.2%)", "47/115 (40.9%)", "", - "", "61/119 (51.3%)", "54/123 (43.9%)", "C: Combination", "(N=132)", - "", "", "37/117 (31.6%)", "59/118 (50%)", "", "50/120 (41.7%)", - "44/114 (38.6%)", "", "", "50/120 (41.7%)", "45/119 (37.8%)" - ), - .Dim = c(13L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt05.R b/tests/testthat/test-table_lbt05.R index 2ff2e27318..fea53f7a32 100644 --- a/tests/testthat/test-table_lbt05.R +++ b/tests/testthat/test-table_lbt05.R @@ -104,28 +104,8 @@ testthat::test_that("LBT05 variant 1 is produced correctly", { result <- trim_rows(result, criteria = all_zero_or_na_not_any) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Laboratory Test", " Direction of abnormality", - "ALT (n)", "Low", "Any Abnormality", "CRP (n)", "Low", "Single, not last", - "Last or replicated", "Any Abnormality", "High", "Single, not last", - "Last or replicated", "Any Abnormality", "IGA (n)", "Low", "Single, not last", - "Last or replicated", "Any Abnormality", "High", "Single, not last", - "Last or replicated", "Any Abnormality", "ARM A", "(N=134)", - "134", "", "0", "134", "", "2 (1.5%)", "10 (7.5%)", "12 (9%)", - "", "1 (0.7%)", "10 (7.5%)", "11 (8.2%)", "134", "", "2 (1.5%)", - "5 (3.7%)", "7 (5.2%)", "", "0", "4 (3%)", "4 (3%)", "ARM B", - "(N=134)", "134", "", "0", "134", "", "0", "7 (5.2%)", "7 (5.2%)", - "", "2 (1.5%)", "9 (6.7%)", "11 (8.2%)", "134", "", "1 (0.7%)", - "8 (6%)", "9 (6.7%)", "", "0", "9 (6.7%)", "9 (6.7%)", "ARM C", - "(N=132)", "132", "", "0", "132", "", "0", "7 (5.3%)", "7 (5.3%)", - "", "1 (0.8%)", "12 (9.1%)", "13 (9.8%)", "132", "", "1 (0.8%)", - "10 (7.6%)", "11 (8.3%)", "", "1 (0.8%)", "5 (3.8%)", "6 (4.5%)" - ), - .Dim = c(23L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LBT05 variant 2 is produced correctly", { @@ -191,30 +171,9 @@ testthat::test_that("LBT05 variant 2 is produced correctly", { ) result <- build_table(lyt, df = adlb, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Laboratory Test", " Direction of abnormality", - "ALT (n)", "Low", "Single, not last", "Last or replicated", "Any Abnormality", - "CRP (n)", "Low", "Single, not last", "Last or replicated", "Any Abnormality", - "High", "Single, not last", "Last or replicated", "Any Abnormality", - "IGA (n)", "Low", "Single, not last", "Last or replicated", "Any Abnormality", - "High", "Single, not last", "Last or replicated", "Any Abnormality", - "ARM A", "(N=134)", "134", "", "0", "0", "0", "134", "", "2 (1.5%)", - "10 (7.5%)", "12 (9%)", "", "1 (0.7%)", "10 (7.5%)", "11 (8.2%)", - "134", "", "2 (1.5%)", "5 (3.7%)", "7 (5.2%)", "", "0", "4 (3%)", - "4 (3%)", "ARM B", "(N=134)", "134", "", "0", "0", "0", "134", - "", "0", "7 (5.2%)", "7 (5.2%)", "", "2 (1.5%)", "9 (6.7%)", - "11 (8.2%)", "134", "", "1 (0.7%)", "8 (6%)", "9 (6.7%)", "", - "0", "9 (6.7%)", "9 (6.7%)", "ARM C", "(N=132)", "132", "", "0", - "0", "0", "132", "", "0", "7 (5.3%)", "7 (5.3%)", "", "1 (0.8%)", - "12 (9.1%)", "13 (9.8%)", "132", "", "1 (0.8%)", "10 (7.6%)", - "11 (8.3%)", "", "1 (0.8%)", "5 (3.8%)", "6 (4.5%)" - ), - .Dim = c(25L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LBT05 variant 4 is produced correctly", { @@ -259,7 +218,6 @@ testthat::test_that("LBT05 variant 4 is produced correctly", { levels = c("Low", "High") )) - map <- unique( adlb[adlb$abn_dir %in% c("Low", "High") & adlb$AVALCAT1 != "", c("PARAMCD", "abn_dir")] ) %>% @@ -287,25 +245,6 @@ testthat::test_that("LBT05 variant 4 is produced correctly", { result <- build_table(lyt, df = adlb, alt_counts_df = adsl) %>% prune_table() - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Laboratory Test", " Direction of abnormality", - "CRP (n)", "Low", "Single, not last", "Last or replicated", "Any Abnormality", - "High", "Single, not last", "Last or replicated", "Any Abnormality", - "IGA (n)", "Low", "Single, not last", "Last or replicated", "Any Abnormality", - "High", "Single, not last", "Last or replicated", "Any Abnormality", - "ARM A", "(N=134)", "134", "", "2 (1.5%)", "10 (7.5%)", "12 (9%)", - "", "1 (0.7%)", "10 (7.5%)", "11 (8.2%)", "134", "", "2 (1.5%)", - "5 (3.7%)", "7 (5.2%)", "", "0", "4 (3%)", "4 (3%)", "ARM B", - "(N=134)", "134", "", "0", "7 (5.2%)", "7 (5.2%)", "", "2 (1.5%)", - "9 (6.7%)", "11 (8.2%)", "134", "", "1 (0.7%)", "8 (6%)", "9 (6.7%)", - "", "0", "9 (6.7%)", "9 (6.7%)", "ARM C", "(N=132)", "132", "", - "0", "7 (5.3%)", "7 (5.3%)", "", "1 (0.8%)", "12 (9.1%)", "13 (9.8%)", - "132", "", "1 (0.8%)", "10 (7.6%)", "11 (8.3%)", "", "1 (0.8%)", - "5 (3.8%)", "6 (4.5%)" - ), - .Dim = c(20L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt06.R b/tests/testthat/test-table_lbt06.R index 448b8fb694..52ff7ec144 100644 --- a/tests/testthat/test-table_lbt06.R +++ b/tests/testthat/test-table_lbt06.R @@ -1,4 +1,5 @@ -# Tests all variants of LBT06. +# Tests all variants of LBT06 + adsl <- adsl_raw adlb <- adlb_raw @@ -19,47 +20,6 @@ testthat::test_that("LBT06 default variant is produced correctly", { ) %>% build_table(adlb, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Alanine Aminotransferase Measurement", "WEEK 1 DAY 8", - "Low", "Not low baseline status", "Low baseline status", "Total", - "High", "Not high baseline status", "High baseline status", "Total", - "WEEK 2 DAY 15", "Low", "Not low baseline status", "Low baseline status", - "Total", "High", "Not high baseline status", "High baseline status", - "Total", "WEEK 3 DAY 22", "Low", "Not low baseline status", "Low baseline status", - "Total", "High", "Not high baseline status", "High baseline status", - "Total", "WEEK 4 DAY 29", "Low", "Not low baseline status", "Low baseline status", - "Total", "High", "Not high baseline status", "High baseline status", - "Total", "WEEK 5 DAY 36", "Low", "Not low baseline status", "Low baseline status", - "Total", "High", "Not high baseline status", "High baseline status", - "Total", "A: Drug X", "(N=134)", "", "", "", "10/124 (8.1%)", - "2/10 (20%)", "12/134 (9%)", "", "10/121 (8.3%)", "1/13 (7.7%)", - "11/134 (8.2%)", "", "", "13/124 (10.5%)", "2/10 (20%)", "15/134 (11.2%)", - "", "8/121 (6.6%)", "1/13 (7.7%)", "9/134 (6.7%)", "", "", "12/124 (9.7%)", - "1/10 (10%)", "13/134 (9.7%)", "", "12/121 (9.9%)", "1/13 (7.7%)", - "13/134 (9.7%)", "", "", "10/124 (8.1%)", "0/10", "10/134 (7.5%)", - "", "12/121 (9.9%)", "3/13 (23.1%)", "15/134 (11.2%)", "", "", - "14/124 (11.3%)", "2/10 (20%)", "16/134 (11.9%)", "", "16/121 (13.2%)", - "1/13 (7.7%)", "17/134 (12.7%)", "B: Placebo", "(N=134)", "", - "", "", "8/122 (6.6%)", "0/12", "8/134 (6%)", "", "11/118 (9.3%)", - "2/16 (12.5%)", "13/134 (9.7%)", "", "", "8/122 (6.6%)", "0/12", - "8/134 (6%)", "", "13/118 (11%)", "2/16 (12.5%)", "15/134 (11.2%)", - "", "", "13/122 (10.7%)", "2/12 (16.7%)", "15/134 (11.2%)", "", - "16/118 (13.6%)", "2/16 (12.5%)", "18/134 (13.4%)", "", "", "13/122 (10.7%)", - "2/12 (16.7%)", "15/134 (11.2%)", "", "8/118 (6.8%)", "2/16 (12.5%)", - "10/134 (7.5%)", "", "", "15/122 (12.3%)", "3/12 (25%)", "18/134 (13.4%)", - "", "9/118 (7.6%)", "2/16 (12.5%)", "11/134 (8.2%)", "C: Combination", - "(N=132)", "", "", "", "6/117 (5.1%)", "0/15", "6/132 (4.5%)", - "", "11/118 (9.3%)", "1/14 (7.1%)", "12/132 (9.1%)", "", "", - "13/117 (11.1%)", "0/15", "13/132 (9.8%)", "", "15/118 (12.7%)", - "1/14 (7.1%)", "16/132 (12.1%)", "", "", "6/117 (5.1%)", "3/15 (20%)", - "9/132 (6.8%)", "", "14/118 (11.9%)", "0/14", "14/132 (10.6%)", - "", "", "10/117 (8.5%)", "0/15", "10/132 (7.6%)", "", "18/118 (15.3%)", - "1/14 (7.1%)", "19/132 (14.4%)", "", "", "10/117 (8.5%)", "1/15 (6.7%)", - "11/132 (8.3%)", "", "10/118 (8.5%)", "0/14", "10/132 (7.6%)" - ), - .Dim = c(48L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt07.R b/tests/testthat/test-table_lbt07.R index ebf5fa10b6..361a3adeaa 100644 --- a/tests/testthat/test-table_lbt07.R +++ b/tests/testthat/test-table_lbt07.R @@ -1,4 +1,5 @@ -# Tests LBT07. +# Tests LBT07 + adsl <- adsl_raw adlb <- adlb_raw @@ -71,129 +72,7 @@ testthat::test_that("LBT07 is produced correctly", { ) result <- build_table(lyt, adlb_f, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- - structure( - c( - "PARAM", - " Direction of abnormality", - "Alanine Aminotransferase Measurement (n)", - "LOW", - "1", - "2", - "3", - "4", - "Any", - "C-Reactive Protein Measurement (n)", - "LOW", - "1", - "2", - "3", - "4", - "Any", - "HIGH", - "1", - "2", - "3", - "4", - "Any", - "Immunoglobulin A Measurement (n)", - "HIGH", - "1", - "2", - "3", - "4", - "Any", - "ARM A", - "(N=134)", - "134", - "", - "14 (10.4%)", - "13 (9.7%)", - "20 (14.9%)", - "7 (5.2%)", - "54 (40.3%)", - "134", - "", - "16 (11.9%)", - "21 (15.7%)", - "12 (9%)", - "11 (8.2%)", - "60 (44.8%)", - "", - "17 (12.7%)", - "15 (11.2%)", - "16 (11.9%)", - "12 (9%)", - "60 (44.8%)", - "134", - "", - "25 (18.7%)", - "14 (10.4%)", - "12 (9%)", - "11 (8.2%)", - "62 (46.3%)", - "ARM B", - "(N=134)", - "134", - "", - "15 (11.2%)", - "18 (13.4%)", - "12 (9%)", - "8 (6%)", - "53 (39.6%)", - "134", - "", - "19 (14.2%)", - "13 (9.7%)", - "9 (6.7%)", - "7 (5.2%)", - "48 (35.8%)", - "", - "15 (11.2%)", - "16 (11.9%)", - "12 (9%)", - "12 (9%)", - "55 (41%)", - "134", - "", - "14 (10.4%)", - "20 (14.9%)", - "13 (9.7%)", - "13 (9.7%)", - "60 (44.8%)", - "ARM C", - "(N=132)", - "132", - "", - "10 (7.6%)", - "11 (8.3%)", - "10 (7.6%)", - "10 (7.6%)", - "41 (31.1%)", - "132", - "", - "15 (11.4%)", - "16 (12.1%)", - "18 (13.6%)", - "5 (3.8%)", - "54 (40.9%)", - "", - "9 (6.8%)", - "13 (9.8%)", - "14 (10.6%)", - "10 (7.6%)", - "46 (34.8%)", - "132", - "", - "13 (9.8%)", - "16 (12.1%)", - "17 (12.9%)", - "4 (3%)", - "50 (37.9%)" - ), - .Dim = c(29L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt08.R b/tests/testthat/test-table_lbt08.R index 87419db5f4..8dfac699ec 100644 --- a/tests/testthat/test-table_lbt08.R +++ b/tests/testthat/test-table_lbt08.R @@ -34,33 +34,6 @@ testthat::test_that("LBT08 produce correctly", { ) %>% build_table(df = df, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "PARAMCD", " GRADDR", "ALT", "High", "1", - "2", "3", "4", "Any", "Low", "1", "2", "3", "4", "Any", "CRP", - "Low", "1", "2", "3", "4", "Any", "IGA", "High", "1", "2", "3", - "4", "Any", "ARM A", "(N=134)", "", "", "16/121 (13.2%)", "14/125 (11.2%)", - "9/129 (7%)", "12/131 (9.2%)", "51/131 (38.9%)", "", "13/124 (10.5%)", - "13/127 (10.2%)", "19/129 (14.7%)", "7/131 (5.3%)", "52/131 (39.7%)", - "", "", "14/122 (11.5%)", "21/124 (16.9%)", "12/129 (9.3%)", - "10/131 (7.6%)", "57/131 (43.5%)", "", "", "24/118 (20.3%)", - "13/120 (10.8%)", "11/124 (8.9%)", "11/129 (8.5%)", "59/129 (45.7%)", - "ARM B", "(N=134)", "", "", "13/117 (11.1%)", "12/121 (9.9%)", - "15/125 (12%)", "11/130 (8.5%)", "51/130 (39.2%)", "", "12/121 (9.9%)", - "17/127 (13.4%)", "12/128 (9.4%)", "7/131 (5.3%)", "48/131 (36.6%)", - "", "", "17/125 (13.6%)", "12/130 (9.2%)", "9/131 (6.9%)", "7/133 (5.3%)", - "45/133 (33.8%)", "", "", "12/120 (10%)", "19/124 (15.3%)", "10/128 (7.8%)", - "13/130 (10%)", "54/130 (41.5%)", "ARM C", "(N=132)", "", "", - "17/117 (14.5%)", "17/120 (14.2%)", "13/124 (10.5%)", "13/129 (10.1%)", - "60/129 (46.5%)", "", "9/117 (7.7%)", "11/124 (8.9%)", "10/128 (7.8%)", - "10/132 (7.6%)", "40/132 (30.3%)", "", "", "13/120 (10.8%)", - "16/125 (12.8%)", "17/126 (13.5%)", "4/127 (3.1%)", "50/127 (39.4%)", - "", "", "13/119 (10.9%)", "13/125 (10.4%)", "17/128 (13.3%)", - "4/130 (3.1%)", "47/130 (36.2%)" - ), - .Dim = c(29L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lbt14.R b/tests/testthat/test-table_lbt14.R index d2c43072fb..b9d4f53aed 100644 --- a/tests/testthat/test-table_lbt14.R +++ b/tests/testthat/test-table_lbt14.R @@ -35,7 +35,6 @@ testthat::test_that("LBT14 variant 1: HIGH works as expected", { BTOXGR_GP = factor(BTOXGR_GP, levels = c("Not High", "1", "2", "3", "4", "Missing")) ) - result <- basic_table() %>% split_cols_by("ARMCD") %>% add_colcounts() %>% @@ -45,34 +44,8 @@ testthat::test_that("LBT14 variant 1: HIGH works as expected", { count_occurrences("ATOXGR_GP", denom = "n", drop = TRUE) %>% build_table(df = adlb_out, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "ALT", "Not High (n)", "Not High", "1", "2", "3", "4", - "1 (n)", "Not High", "1", "2", "3", "4", - "2 (n)", "Not High", "1", "2", - "3 (n)", "Not High", "1", "2", "4", - "4 (n)", "Not High", "1", "3", - "ARM A", "(N=134)", "", "121", "72 (59.5%)", "16 (13.2%)", "13 (10.7%)", "9 (7.4%)", "11 (9.1%)", - "4", "1 (25.0%)", "1 (25.0%)", "1 (25.0%)", "0", "1 (25.0%)", - "4", "3 (75.0%)", "0", "1 (25.0%)", - "2", "2 (100%)", "0", "0", "0", - "3", "1 (33.3%)", "1 (33.3%)", "1 (33.3%)", - "ARM B", "(N=134)", "", "118", "70 (59.3%)", "13 (11.0%)", "12 (10.2%)", "14 (11.9%)", "9 (7.6%)", - "4", "1 (25.0%)", "0", "0", "1 (25.0%)", "2 (50.0%)", - "4", "3 (75.0%)", "1 (25.0%)", "0", - "5", "2 (40.0%)", "2 (40.0%)", "1 (20.0%)", "0", - "3", "2 (66.7%)", "0", "1 (33.3%)", - "ARM C", "(N=132)", "", "118", "59 (50.0%)", "17 (14.4%)", "18 (15.3%)", "12 (10.2%)", "12 (10.2%)", - "3", "2 (66.7%)", "0", "0", "1 (33.3%)", "0", - "4", "3 (75.0%)", "1 (25.0%)", "0", - "5", "4 (80.0%)", "0", "0", "1 (20.0%)", - "2", "2 (100%)", "0", "0" - ), - .Dim = c(28L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LBT14 variant 2: LOW works as expected", { @@ -118,34 +91,8 @@ testthat::test_that("LBT14 variant 2: LOW works as expected", { count_occurrences("ATOXGR_GP", denom = "n", drop = TRUE) %>% build_table(df = adlb_out, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "ALT", "Not Low (n)", "Not Low", "1", "2", "3", "4", - "1 (n)", "Not Low", "1", "2", "3", "4", - "2 (n)", "Not Low", "2", "3", - "3 (n)", "Not Low", "1", - "4 (n)", "Not Low", "3", "4", - "ARM A", "(N=134)", "", "124", "74 (59.7%)", "13 (10.5%)", "13 (10.5%)", "17 (13.7%)", "7 (5.6%)", - "3", "0", "1 (33.3%)", "0", "2 (66.7%)", "0", - "2", "2 (100%)", "0", "0", - "2", "2 (100%)", "0", - "3", "2 (66.7%)", "1 (33.3%)", "0", - "ARM B", "(N=134)", "", "122", "76 (62.3%)", "12 (9.8%)", "16 (13.1%)", "11 (9.0%)", "7 (5.7%)", - "6", "2 (33.3%)", "2 (33.3%)", "1 (16.7%)", "1 (16.7%)", "0", - "1", "0", "1 (100%)", "0", - "3", "2 (66.7%)", "1 (33.3%)", - "2", "1 (50.0%)", "0", "1 (50.0%)", - "ARM C", "(N=132)", "", "117", "80 (68.4%)", "9 (7.7%)", "11 (9.4%)", "9 (7.7%)", "8 (6.8%)", - "7", "5 (71.4%)", "0", "0", "0", "2 (28.6%)", - "4", "3 (75.0%)", "0", "1 (25.0%)", - "4", "3 (75.0%)", "1 (25.0%)", - "0", "0", "0", "0" - ), - .Dim = c(26L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LBT14 variant 3: LOW without baseline missing works as expected", { @@ -181,7 +128,6 @@ testthat::test_that("LBT14 variant 3: LOW without baseline missing works as expe BTOXGR_GP = factor(BTOXGR_GP, levels = c("Not Low", "1", "2", "3", "4")) ) - result <- basic_table() %>% split_cols_by("ARMCD") %>% add_colcounts() %>% @@ -191,34 +137,8 @@ testthat::test_that("LBT14 variant 3: LOW without baseline missing works as expe count_occurrences("ATOXGR_GP", denom = "n", drop = TRUE) %>% build_table(df = adlb_out, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "ALT", "Not Low (n)", "Not Low", "1", "2", "3", "4", - "1 (n)", "Not Low", "1", "2", "3", "4", - "2 (n)", "Not Low", "2", "3", - "3 (n)", "Not Low", "1", - "4 (n)", "Not Low", "3", "4", - "ARM A", "(N=134)", "", "124", "74 (59.7%)", "13 (10.5%)", "13 (10.5%)", "17 (13.7%)", "7 (5.6%)", - "3", "0", "1 (33.3%)", "0", "2 (66.7%)", "0", - "2", "2 (100%)", "0", "0", - "2", "2 (100%)", "0", "3", - "2 (66.7%)", "1 (33.3%)", "0", - "ARM B", "(N=134)", "", "122", "76 (62.3%)", "12 (9.8%)", "16 (13.1%)", "11 (9.0%)", "7 (5.7%)", - "6", "2 (33.3%)", "2 (33.3%)", "1 (16.7%)", "1 (16.7%)", "0", - "1", "0", "1 (100%)", "0", - "3", "2 (66.7%)", "1 (33.3%)", - "2", "1 (50.0%)", "0", "1 (50.0%)", - "ARM C", "(N=132)", "", "117", "80 (68.4%)", "9 (7.7%)", "11 (9.4%)", "9 (7.7%)", "8 (6.8%)", - "7", "5 (71.4%)", "0", "0", "0", "2 (28.6%)", - "4", "3 (75.0%)", "0", "1 (25.0%)", - "4", "3 (75.0%)", "1 (25.0%)", - "0", "0", "0", "0" - ), - .Dim = c(26L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LBT14 variant 4: LOW and force 1 missing both baseline and post-baseline, then force the missing baseline as 0 as expected", { # nolint @@ -256,7 +176,6 @@ testthat::test_that("LBT14 variant 4: LOW and force 1 missing both baseline and BTOXGR_GP = factor(BTOXGR_GP, levels = c("Not Low", "1", "2", "3", "4")) ) - result <- basic_table() %>% split_cols_by("ARMCD") %>% add_colcounts() %>% @@ -266,34 +185,8 @@ testthat::test_that("LBT14 variant 4: LOW and force 1 missing both baseline and count_occurrences("ATOXGR_GP", denom = "n", drop = TRUE) %>% build_table(df = adlb_out, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "ALT", "Not Low (n)", "Not Low", "1", "2", "3", "4", "Missing", - "1 (n)", "Not Low", "1", "2", "3", "4", - "2 (n)", "Not Low", "2", "3", - "3 (n)", "Not Low", "1", - "4 (n)", "Not Low", "3", "4", - "ARM A", "(N=134)", "", "124", "74 (59.7%)", "13 (10.5%)", "13 (10.5%)", "16 (12.9%)", "7 (5.6%)", "1 (0.8%)", - "3", "0", "1 (33.3%)", "0", "2 (66.7%)", "0", - "2", "2 (100%)", "0", "0", - "2", "2 (100%)", "0", - "3", "2 (66.7%)", "1 (33.3%)", "0", - "ARM B", "(N=134)", "", "122", "76 (62.3%)", "12 (9.8%)", "16 (13.1%)", "11 (9.0%)", "7 (5.7%)", "0", - "6", "2 (33.3%)", "2 (33.3%)", "1 (16.7%)", "1 (16.7%)", "0", - "1", "0", "1 (100%)", "0", - "3", "2 (66.7%)", "1 (33.3%)", - "2", "1 (50.0%)", "0", "1 (50.0%)", - "ARM C", "(N=132)", "", "117", "80 (68.4%)", "9 (7.7%)", "11 (9.4%)", "9 (7.7%)", "8 (6.8%)", "0", - "7", "5 (71.4%)", "0", "0", "0", "2 (28.6%)", - "4", "3 (75.0%)", "0", "1 (25.0%)", - "4", "3 (75.0%)", "1 (25.0%)", - "0", "0", "0", "0" - ), - .Dim = c(27L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LBT14 variant 5: HIGH with fillings works as expected", { @@ -330,7 +223,6 @@ testthat::test_that("LBT14 variant 5: HIGH with fillings works as expected", { BTOXGR_GP = factor(BTOXGR_GP, levels = c("Not High", "1", "2", "3", "4", "Missing")) ) - result <- basic_table() %>% split_cols_by("ARMCD") %>% add_colcounts() %>% @@ -340,36 +232,6 @@ testthat::test_that("LBT14 variant 5: HIGH with fillings works as expected", { count_occurrences("ATOXGR_GP", denom = "n", drop = FALSE) %>% build_table(df = adlb_out, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "ALT", "Not High (n)", "Not High", "1", "2", "3", "4", "Missing", - "1 (n)", "Not High", "1", "2", "3", "4", "Missing", - "2 (n)", "Not High", "1", "2", "3", "4", "Missing", - "3 (n)", "Not High", "1", "2", "3", "4", "Missing", - "4 (n)", "Not High", "1", "2", "3", "4", "Missing", - "Missing (n)", "Not High", "1", "2", "3", "4", "Missing", - "ARM A", "(N=134)", "", "121", "72 (59.5%)", "16 (13.2%)", "13 (10.7%)", "9 (7.4%)", "11 (9.1%)", "0", - "4", "1 (25.0%)", "1 (25.0%)", "1 (25.0%)", "0", "1 (25.0%)", "0", - "4", "3 (75.0%)", "0", "1 (25.0%)", "0", "0", "0", - "2", "2 (100%)", "0", "0", "0", "0", "0", - "3", "1 (33.3%)", "1 (33.3%)", "0", "1 (33.3%)", "0", "0", - "0", "0", "0", "0", "0", "0", "0", - "ARM B", "(N=134)", "", "118", "70 (59.3%)", "13 (11.0%)", "12 (10.2%)", "14 (11.9%)", "9 (7.6%)", "0", - "4", "1 (25.0%)", "0", "0", "1 (25.0%)", "2 (50.0%)", "0", - "4", "3 (75.0%)", "1 (25.0%)", "0", "0", "0", "0", - "5", "2 (40.0%)", "2 (40.0%)", "1 (20.0%)", "0", "0", "0", - "3", "2 (66.7%)", "0", "0", "1 (33.3%)", "0", "0", - "0", "0", "0", "0", "0", "0", "0", - "ARM C", "(N=132)", "", "118", "59 (50.0%)", "17 (14.4%)", "18 (15.3%)", "12 (10.2%)", "12 (10.2%)", "0", - "3", "2 (66.7%)", "0", "0", "1 (33.3%)", "0", "0", - "4", "3 (75.0%)", "1 (25.0%)", "0", "0", "0", "0", - "5", "4 (80.0%)", "0", "0", "0", "1 (20.0%)", "0", - "2", "2 (100%)", "0", "0", "0", "0", "0", - "0", "0", "0", "0", "0", "0", "0" - ), - .Dim = c(45L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_lgrt02.R b/tests/testthat/test-table_lgrt02.R index 68f925cf05..749d4ad1f4 100644 --- a/tests/testthat/test-table_lgrt02.R +++ b/tests/testthat/test-table_lgrt02.R @@ -1,4 +1,5 @@ -# Tests variants of LGRT02. +# Tests variants of LGRT02 + adsl <- adsl_raw adrs <- adrs_raw @@ -9,7 +10,6 @@ adrs_cached <- adrs %>% dplyr::filter(SEX %in% c("F", "M")) %>% reapply_varlabels(formatters::var_labels(adrs)) - get_adrs <- function() { adrs_f <- adrs_cached %>% dplyr::filter( @@ -48,31 +48,8 @@ testthat::test_that("LGRT02 without interaction term is produced correctly", { ) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Planned Arm Code", "Reference ARM A, n = 134", - "ARM B, n = 134", "ARM C, n = 132", "Sex", "Reference M, n = 169", - "F, n = 231", "Race", "Reference AMERICAN INDIAN OR ALASKA NATIVE, n = 25", - "ASIAN, n = 208", "BLACK OR AFRICAN AMERICAN, n = 91", "WHITE, n = 74", - "MULTIPLE, n = 1", "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER, n = 1", - "Age", "Age", "Degrees of Freedom", "2", "", "1", "1", "", "", - "1", "5", "", "1", "1", "1", "1", "1", "", "1", "Parameter Estimate", - "", "", "-2.162", "-0.090", "", "", "0.364", "", "", "-16.246", - "-15.205", "-15.955", "-0.363", "1.036", "", "0.071", "Standard Error", - "", "", "1.084", "1.426", "", "", "0.701", "", "", "2017.122", - "2017.122", "2017.122", "10941.553", "10941.553", "", "0.053", - "Odds Ratio", "", "", "0.12", "0.91", "", "", "1.44", "", "", - "0.00", "0.00", "0.00", "0.70", "2.82", "", "1.07", "Wald 95% CI", "", - "", "(0.01, 0.96)", "(0.06, 14.97)", "", "", "(0.36, 5.69)", - "", "", "(0.00, >999.99)", "(0.00, >999.99)", "(0.00, >999.99)", - "(0.00, >999.99)", "(0.00, >999.99)", "", "(0.97, 1.19)", "p-value", - "0.0346", "", "0.0461", "0.9499", "", "", "0.6032", "0.9685", - "", "0.9936", "0.9940", "0.9937", "1.0000", "0.9999", "", "0.1866" - ), - .Dim = c(17L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LGRT02 with categorical interaction is produced correctly", { @@ -97,33 +74,8 @@ testthat::test_that("LGRT02 with categorical interaction is produced correctly", ) %>% build_table(df = df) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Age", "Age", "Planned Arm Code", "Reference ARM A, n = 134", - "ARM B, n = 134", "Sex", "F", "M", "ARM C, n = 132", "Sex", "F", - "M", "Sex", "Reference M, n = 169", "F, n = 231", "Planned Arm Code", - "ARM A", "ARM B", "ARM C", "Interaction of Planned Arm Code * Sex", - "Reference ARM A or M, n = 248", "ARM B * F, n = 82", "ARM C * F, n = 70", - "Degrees of Freedom", "", "1", "2", "", "1", "", "", "", "1", - "", "", "", "", "", "1", "", "", "", "", "2", "", "1", "1", "Parameter Estimate", - "", "0.067", "", "", "-17.850", "", "", "", "-16.442", "", "", - "", "", "", "-16.044", "", "", "", "", "", "", "16.373", "32.492", - "Standard Error", "", "0.054", "", "", "2362.767", "", "", "", - "2362.767", "", "", "", "", "", "2362.767", "", "", "", "", "", - "", "2362.767", "3156.732", "Odds Ratio", "", "1.07", "", "", - "", "", "0.23", "0.00", "", "", ">999.99", "0.00", "", "", "", "", - "0.00", "1.39", ">999.99", "", "", "", "", "Wald 95% CI", "", "(0.96, 1.19)", - "", "", "", "", "(0.02, 2.11)", "(0.00, >999.99)", "", "", "(0.00, >999.99)", - "(0.00, >999.99)", "", "", "", "", "(0.00, >999.99)", "(0.29, 6.59)", - "(0.00, >999.99)", "", "", "", "", "p-value", "", "0.2084", "0.4882", - "", "0.9940", "", "", "", "0.9944", "", "", "", "", "", "0.9946", - "", "", "", "", "0.9999", "", "0.9945", "0.9918" - ), - .Dim = c(24L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LGRT02 with continuous interaction is produced correctly", { @@ -148,33 +100,8 @@ testthat::test_that("LGRT02 with continuous interaction is produced correctly", ) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Sex", "Reference M, n = 169", "F, n = 231", - "Planned Arm Code", "Reference ARM A, n = 134", "ARM B, n = 134", - "Age", "18", "65", "ARM C, n = 132", "Age", "18", "65", "Age", - "Age", "Planned Arm Code", "ARM A", "ARM B", "ARM C", "Interaction of Planned Arm Code * Age", - "Reference ARM A, n = 134", "ARM B, n = 134", "ARM C, n = 132", - "Degrees of Freedom", "", "", "1", "2", "", "1", "", "", "", - "1", "", "", "", "", "1", "", "", "", "", "2", "", "1", "1", - "Parameter Estimate", "", "", "0.381", "", "", "20.020", "", "", - "", "15.622", "", "", "", "", "0.877", "", "", "", "", "", "", - "-0.849", "-0.636", "Standard Error", "", "", "0.710", "", "", - "13.714", "", "", "", "14.810", "", "", "", "", "0.581", "", "", - "", "", "", "", "0.583", "0.618", "Odds Ratio", "", "", "1.46", - "", "", "", "", "113.59", "0.00", "", "", "64.74", "0.00", "", "", - "", "2.40", "1.03", "1.27", "", "", "", "", "Wald 95% CI", "", - "", "(0.36, 5.88)", "", "", "", "", "(0.14, >999.99)", "(<0.01, >999.99)", - "", "", "(0.03, >999.99)", "(<0.01, >999.99)", "", "", "", "(0.77, 7.50)", - "(0.93, 1.14)", "(0.84, 1.93)", "", "", "", "", "p-value", "", - "", "0.5915", "0.2768", "", "0.1443", "", "", "", "0.2915", "", - "", "", "", "0.1309", "", "", "", "", "0.2213", "", "0.1449", - "0.3034" - ), - .Dim = c(24L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("LGRT02 with setting values indicating an event and custom alpha level is produced correctly", { @@ -199,29 +126,6 @@ testthat::test_that("LGRT02 with setting values indicating an event and custom a ) %>% build_table(df = df) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "Planned Arm Code", "Reference ARM A, n = 134", - "ARM B, n = 134", "ARM C, n = 132", "Sex", "Reference M, n = 169", - "F, n = 231", "Age", "Age", "Race", "Reference AMERICAN INDIAN OR ALASKA NATIVE, n = 25", - "ASIAN, n = 208", "BLACK OR AFRICAN AMERICAN, n = 91", "WHITE, n = 74", - "MULTIPLE, n = 1", "NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER, n = 1", - "Degrees of Freedom", "2", "", "1", "1", "", "", "1", "", "1", - "5", "", "1", "1", "1", "1", "1", "Parameter Estimate", "", "", - "2.162", "0.090", "", "", "-0.364", "", "-0.071", "", "", "16.246", - "15.205", "15.955", "0.363", "-1.036", "Standard Error", "", - "", "1.084", "1.426", "", "", "0.701", "", "0.053", "", "", "2017.122", - "2017.122", "2017.122", "10941.553", "10941.553", "Odds Ratio", - "", "", "8.69", "1.09", "", "", "0.69", "", "0.93", "", "", ">999.99", - ">999.99", ">999.99", "1.44", "0.35", "Wald 90% CI", "", "", - "(1.46, 51.66)", "(0.10, 11.43)", "", "", "(0.22, 2.20)", "", - "(0.85, 1.02)", "", "", "(0.00, >999.99)", "(0.00, >999.99)", - "(0.00, >999.99)", "(0.00, >999.99)", "(0.00, >999.99)", "p-value", - "0.0346", "", "0.0461", "0.9499", "", "", "0.6032", "", "0.1866", - "0.9685", "", "0.9936", "0.9940", "0.9937", "1.0000", "0.9999" - ), - .Dim = c(17L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_mht01.R b/tests/testthat/test-table_mht01.R index 3db926ae0a..a0074505e2 100644 --- a/tests/testthat/test-table_mht01.R +++ b/tests/testthat/test-table_mht01.R @@ -1,4 +1,5 @@ -# Tests the single variant for MHT01. +# Tests the single variant for MHT01 + adsl <- adsl_raw admh <- admh_raw @@ -35,35 +36,9 @@ testthat::test_that("MHT01 variant 1 is produced accurately", { count_occurrences(vars = "MHDECOD", .indent_mods = -1L) result <- build_table(lyt, admh_f, alt_counts_df = adsl_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one event", - "Total number of events", "cl A", "Total number of patients with at least one event", - "Total number of events", "trm A_1/2", "trm A_2/2", "cl B", "Total number of patients with at least one event", - "Total number of events", "trm B_1/3", "trm B_2/3", "trm B_3/3", - "cl C", "Total number of patients with at least one event", "Total number of events", - "trm C_1/2", "trm C_2/2", "cl D", "Total number of patients with at least one event", - "Total number of events", "trm D_1/3", "trm D_2/3", "trm D_3/3", - "A: Drug X", "(N=134)", "122 (91.0%)", "609", "", "78 (58.2%)", - "132", "50 (37.3%)", "48 (35.8%)", "", "96 (71.6%)", "185", "47 (35.1%)", - "49 (36.6%)", "48 (35.8%)", "", "67 (50.0%)", "103", "43 (32.1%)", - "35 (26.1%)", "", "96 (71.6%)", "189", "50 (37.3%)", "48 (35.8%)", - "47 (35.1%)", "B: Placebo", "(N=134)", "123 (91.8%)", "622", - "", "75 (56.0%)", "130", "45 (33.6%)", "48 (35.8%)", "", "89 (66.4%)", - "198", "49 (36.6%)", "44 (32.8%)", "54 (40.3%)", "", "75 (56.0%)", - "116", "46 (34.3%)", "48 (35.8%)", "", "90 (67.2%)", "178", "42 (31.3%)", - "42 (31.3%)", "58 (43.3%)", "C: Combination", "(N=132)", "120 (90.9%)", - "703", "", "89 (67.4%)", "160", "63 (47.7%)", "50 (37.9%)", "", - "97 (73.5%)", "205", "43 (32.6%)", "52 (39.4%)", "51 (38.6%)", - "", "79 (59.8%)", "129", "43 (32.6%)", "55 (41.7%)", "", "98 (74.2%)", - "209", "51 (38.6%)", "50 (37.9%)", "57 (43.2%)" - ), - .Dim = c(26L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("MHT01 variant 2 is produced accurately", { @@ -102,20 +77,9 @@ testthat::test_that("MHT01 variant 2 is produced accurately", { count_occurrences(vars = "MHDECOD", .indent_mods = -1L) result <- build_table(lyt, admh_f_prior, alt_counts_df = adsl_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one event", - "Total number of events", "cl D", "Total number of patients with at least one event", - "Total number of events", "trm D_2/3", "A: Drug X", "(N=134)", "0", "0", "", "0", "0", "0", - "B: Placebo", "(N=134)", "0", "0", "", "0", "0", "0", - "C: Combination", "(N=132)", "1 (0.8%)", "1", "", "1 (0.8%)", "1", "1 (0.8%)" - ), - .Dim = c(8L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("MHT01 variant 3 is produced accurately", { @@ -151,32 +115,9 @@ testthat::test_that("MHT01 variant 3 is produced accurately", { count_occurrences(vars = "MHDECOD", .indent_mods = -1L) result <- build_table(lyt, admh_f, alt_counts_df = adsl_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one event", - "cl A", "Total number of patients with at least one event", "trm A_1/2", - "trm A_2/2", "cl B", "Total number of patients with at least one event", - "trm B_1/3", "trm B_2/3", "trm B_3/3", "cl C", "Total number of patients with at least one event", - "trm C_1/2", "trm C_2/2", "cl D", "Total number of patients with at least one event", - "trm D_1/3", "trm D_2/3", "trm D_3/3", "A: Drug X", "(N=134)", - "122 (91.0%)", "", "78 (58.2%)", "50 (37.3%)", "48 (35.8%)", "", - "96 (71.6%)", "47 (35.1%)", "49 (36.6%)", "48 (35.8%)", "", "67 (50.0%)", - "43 (32.1%)", "35 (26.1%)", "", "96 (71.6%)", "50 (37.3%)", "48 (35.8%)", - "47 (35.1%)", "B: Placebo", "(N=134)", "123 (91.8%)", "", "75 (56.0%)", - "45 (33.6%)", "48 (35.8%)", "", "89 (66.4%)", "49 (36.6%)", "44 (32.8%)", - "54 (40.3%)", "", "75 (56.0%)", "46 (34.3%)", "48 (35.8%)", "", - "90 (67.2%)", "42 (31.3%)", "42 (31.3%)", "58 (43.3%)", "C: Combination", - "(N=132)", "120 (90.9%)", "", "89 (67.4%)", "63 (47.7%)", "50 (37.9%)", - "", "97 (73.5%)", "43 (32.6%)", "52 (39.4%)", "51 (38.6%)", "", - "79 (59.8%)", "43 (32.6%)", "55 (41.7%)", "", "98 (74.2%)", "51 (38.6%)", - "50 (37.9%)", "57 (43.2%)" - ), - .Dim = c(21L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) # MHT01 variant 4 can not be produced by current rtables @@ -217,37 +158,7 @@ testthat::test_that("MHT01 variant 5 is produced accurately", { count_occurrences(vars = "MHDECOD", .indent_mods = -1L) result <- build_table(lyt, admh_f, alt_counts_df = adsl_f) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Total number of patients with at least one event", - "Number of events", "cl A", "Total number of patients with at least one event", - "Number of events", "trm A_1/2", "trm A_2/2", "cl B", "Total number of patients with at least one event", - "Number of events", "trm B_1/3", "trm B_2/3", "trm B_3/3", "cl C", - "Total number of patients with at least one event", "Number of events", - "trm C_1/2", "trm C_2/2", "cl D", "Total number of patients with at least one event", - "Number of events", "trm D_1/3", "trm D_2/3", "trm D_3/3", "A: Drug X", - "(N=134)", "122 (91.0%)", "609", "", "78 (58.2%)", "132", "50 (37.3%)", - "48 (35.8%)", "", "96 (71.6%)", "185", "47 (35.1%)", "49 (36.6%)", - "48 (35.8%)", "", "67 (50.0%)", "103", "43 (32.1%)", "35 (26.1%)", - "", "96 (71.6%)", "189", "50 (37.3%)", "48 (35.8%)", "47 (35.1%)", - "B: Placebo", "(N=134)", "123 (91.8%)", "622", "", "75 (56.0%)", - "130", "45 (33.6%)", "48 (35.8%)", "", "89 (66.4%)", "198", "49 (36.6%)", - "44 (32.8%)", "54 (40.3%)", "", "75 (56.0%)", "116", "46 (34.3%)", - "48 (35.8%)", "", "90 (67.2%)", "178", "42 (31.3%)", "42 (31.3%)", - "58 (43.3%)", "C: Combination", "(N=132)", "120 (90.9%)", "703", - "", "89 (67.4%)", "160", "63 (47.7%)", "50 (37.9%)", "", "97 (73.5%)", - "205", "43 (32.6%)", "52 (39.4%)", "51 (38.6%)", "", "79 (59.8%)", - "129", "43 (32.6%)", "55 (41.7%)", "", "98 (74.2%)", "209", "51 (38.6%)", - "50 (37.9%)", "57 (43.2%)", "All Patients", "(N=400)", "365 (91.2%)", - "1934", "", "242 (60.5%)", "422", "158 (39.5%)", "146 (36.5%)", - "", "282 (70.5%)", "588", "139 (34.8%)", "145 (36.2%)", "153 (38.2%)", - "", "221 (55.2%)", "348", "132 (33.0%)", "138 (34.5%)", "", "284 (71.0%)", - "576", "143 (35.8%)", "140 (35.0%)", "162 (40.5%)" - ), - .Dim = c(26L, 5L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_onct05.R b/tests/testthat/test-table_onct05.R index c5e978055a..a45b6f5b36 100644 --- a/tests/testthat/test-table_onct05.R +++ b/tests/testthat/test-table_onct05.R @@ -29,23 +29,8 @@ testthat::test_that("ONCT05 variant 1 (Objective Response Rate by Subgroup) is p result <- basic_table() %>% tabulate_rsp_subgroups(df) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", "F", "M", "Stratification Factor 2", - "S1", "S2", " ", "Total n", "200", "", "120", "80", "", "105", - "95", "B: Placebo", "n", "100", "", "62", "38", "", "48", "52", - "B: Placebo", "Response (%)", "71.0%", "", "64.5%", "81.6%", "", - "70.8%", "71.2%", "A: Drug X", "n", "100", "", "58", "42", "", - "57", "43", "A: Drug X", "Response (%)", "90.0%", "", "91.4%", - "88.1%", "", "89.5%", "90.7%", " ", "Odds Ratio", "3.68", "", - "5.83", "1.67", "", "3.50", "3.95", " ", "95% CI", "(1.68, 8.04)", - "", "(2.03, 16.73)", "(0.48, 5.79)", "", "(1.22, 10.00)", "(1.20, 13.01)" - ), - .Dim = 9:8 - ) - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("ONCT05 variant 2 (Specifying class variables) is produced correctly", { @@ -68,25 +53,8 @@ testthat::test_that("ONCT05 variant 2 (Specifying class variables) is produced c result <- basic_table() %>% tabulate_rsp_subgroups(df) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", "M", "F", "Stratification Factor 1", - "C", "B", "A", " ", "Total n", "200", "", "80", "120", "", "72", - "71", "57", "B: Placebo", "n", "100", "", "38", "62", "", "36", - "35", "29", "B: Placebo", "Response (%)", "71.0%", "", "81.6%", - "64.5%", "", "72.2%", "74.3%", "65.5%", "A: Drug X", "n", "100", - "", "42", "58", "", "36", "36", "28", "A: Drug X", "Response (%)", - "90.0%", "", "88.1%", "91.4%", "", "94.4%", "77.8%", "100.0%", " ", - "Odds Ratio", "3.68", "", "1.67", "5.83", "", "6.54", "1.21", - ">999.99", " ", "95% CI", "(1.68, 8.04)", "", "(0.48, 5.79)", - "(2.03, 16.73)", "", "(1.32, 32.44)", "(0.41, 3.61)", "(0.00, >999.99)" - ), - .Dim = c(10L, 8L) - ) - - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("ONCT05 variant 3 (selecting columns and changing the alpha level) is produced correctly", { @@ -103,20 +71,8 @@ testthat::test_that("ONCT05 variant 3 (selecting columns and changing the alpha result <- basic_table() %>% tabulate_rsp_subgroups(df, vars = c("n_tot", "or", "ci", "pval")) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", "F", "M", "Stratification Factor 2", - "S1", "S2", " ", "Total n", "200", "", "120", "80", "", "105", - "95", " ", "Odds Ratio", "3.68", "", "5.83", "1.67", "", "3.50", - "3.95", " ", "90% CI", "(1.91, 7.09)", "", "(2.41, 14.12)", "(0.59, 4.74)", - "", "(1.45, 8.45)", "(1.45, 10.74)", " ", "p-value (Chi-Squared Test)", - "0.0007", "", "0.0004", "0.4150", "", "0.0154", "0.0178" - ), - .Dim = c(9L, 5L) - ) - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("ONCT05 variant 4 (setting values indicating response) is produced correctly", { @@ -136,22 +92,6 @@ testthat::test_that("ONCT05 variant 4 (setting values indicating response) is pr result <- basic_table() %>% tabulate_rsp_subgroups(df) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Baseline Risk Factors", "", "All Patients", "Sex", "F", "M", "Stratification Factor 2", - "S1", "S2", " ", "Total n", "200", "", "120", "80", "", "105", - "95", "B: Placebo", "n", "100", "", "62", "38", "", "48", "52", - "B: Placebo", "Response (%)", "95.0%", "", "96.8%", "92.1%", "", - "97.9%", "92.3%", "A: Drug X", "n", "100", "", "58", "42", "", - "57", "43", "A: Drug X", "Response (%)", "99.0%", "", "98.3%", - "100.0%", "", "100.0%", "97.7%", " ", "Odds Ratio", "5.21", "", "1.90", - ">999.99", "", ">999.99", "3.50", " ", "95% CI", "(0.60, 45.43)", - "", "(0.17, 21.53)", "(0.00, >999.99)", "", "(0.00, >999.99)", - "(0.38, 32.55)" - ), - .Dim = 9:8 - ) - testthat::expect_equal(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_pdt01.R b/tests/testthat/test-table_pdt01.R index f8fca2be17..cfb0a7a86e 100644 --- a/tests/testthat/test-table_pdt01.R +++ b/tests/testthat/test-table_pdt01.R @@ -34,43 +34,6 @@ testthat::test_that("PDT01 is produced correctly", { prune_table() %>% sort_at_path(path = c("DVDECOD", "*", "DVTERM"), scorefun = score_occurrences) - result_matrix <- to_string_matrix(result) - expected_matrix <- matrix( - c( - "Protocol Deviation Coded Term", "A: Drug X", "B: Placebo", "C: Combination", - " Protocol Deviation Term", "(N=134)", "(N=134)", "(N=132)", - "Total number of patients with at least one major protocol deviation", "22 (16.4%)", "23 (17.2%)", "13 (9.8%)", - "Total number of major protocol deviations", "40", "42", "21", - "EXCLUSION CRITERIA", "", "", "", - "Active or untreated or other excluded cns metastases", "5 (3.7%)", "3 (2.2%)", "0", - "Pregnancy criteria", "2 (1.5%)", "4 (3.0%)", "0", - "History of other malignancies within the last 5 years", "3 (2.2%)", "2 (1.5%)", "0", - "Uncontrolled concurrent condition", "3 (2.2%)", "1 (0.7%)", "0", - "Other exclusion criteria", "0", "0", "3 (2.3%)", - "Received prior prohibited therapy or medication", "0", "2 (1.5%)", "1 (0.8%)", - "INCLUSION CRITERIA", "", "", "", - "No signed ICF at study entry", "6 (4.5%)", "4 (3.0%)", "0", - "Ineligible cancer type or current cancer stage", "6 (4.5%)", "1 (0.7%)", "1 (0.8%)", - "Inclusion lab values outside allowed limits", "0", "3 (2.2%)", "0", - "Does not meet prior therapy requirements", "1 (0.7%)", "0", "0", - "Inclusion-related test not done/out of window", "0", "0", "1 (0.8%)", - "MEDICATION", "", "", "", - "Significant deviation from planned dose", "3 (2.2%)", "1 (0.7%)", "2 (1.5%)", - "Received incorrect study medication", "1 (0.7%)", "2 (1.5%)", "1 (0.8%)", - "Discontinued study drug for unspecified reason", "1 (0.7%)", "1 (0.7%)", "1 (0.8%)", - "Dose missed or significantly out of window", "2 (1.5%)", "0", "1 (0.8%)", - "Received prohibited concomitant medication", "0", "2 (1.5%)", "0", - "PROCEDURAL", "", "", "", - "Eligibility-related test not done/out of window", "1 (0.7%)", "6 (4.5%)", "1 (0.8%)", - "Omission of screening tumor assessment", "0", "4 (3.0%)", "3 (2.3%)", - "Missed assessment affecting safety/study outcomes", "1 (0.7%)", "2 (1.5%)", "2 (1.5%)", - "Failure to sign updated ICF within two visits", "2 (1.5%)", "1 (0.7%)", "1 (0.8%)", - "Missed 2 or more efficacy assessments", "2 (1.5%)", "0", "1 (0.8%)", - "Omission of complete lab panel required by protocol", "0", "1 (0.7%)", "1 (0.8%)" - ), - nrow = 30, ncol = 4, - byrow = TRUE - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_pdt02.R b/tests/testthat/test-table_pdt02.R index 1c17ce5367..244d7c34a1 100644 --- a/tests/testthat/test-table_pdt02.R +++ b/tests/testthat/test-table_pdt02.R @@ -29,23 +29,6 @@ testthat::test_that("PDT02 is produced correctly", { result <- build_table(lyt, addv_pan, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- matrix( - c( - "Reason for Deviation", "A: Drug X", "B: Placebo", "C: Combination", - " Protocol Deviation Term", "(N=134)", "(N=134)", "(N=132)", - "Total number of patients with at least one major protocol deviation related to epidemic/pandemic", - "9 (6.7%)", "2 (1.5%)", "5 (3.8%)", - "Total number of major protocol deviations related to epidemic/pandemic", "9", "2", "6", - "Site action due to epidemic/pandemic (n)", "9", "2", "5", - "Dose missed or significantly out of window", "2 (1.5%)", "0", "1 (0.8%)", - "Failure to sign updated ICF within two visits", "2 (1.5%)", "1 (0.7%)", "1 (0.8%)", - "Missed 2 or more efficacy assessments", "2 (1.5%)", "0", "1 (0.8%)", - "Significant deviation from planned dose", "3 (2.2%)", "1 (0.7%)", "2 (1.5%)" - ), - nrow = 9, ncol = 4, - byrow = TRUE - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_pkct01.R b/tests/testthat/test-table_pkct01.R index 2837ced02c..090230ab47 100644 --- a/tests/testthat/test-table_pkct01.R +++ b/tests/testthat/test-table_pkct01.R @@ -1,4 +1,5 @@ -# Preparation of the test case. +# Preparation of the test case + adpc <- adpc_raw testthat::test_that("PKCT01 is produced correctly", { @@ -15,27 +16,8 @@ testthat::test_that("PKCT01 is produced correctly", { result <- build_table(l, df = adpc) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "A: Drug X", "Plasma Drug X", " ", "Plasma Drug Y", " ", - "Urine Drug X", " ", "Urine Drug Y", " ", "C: Combination", - "Plasma Drug X", " ", "Plasma Drug Y", " ", "Urine Drug X", " ", - "Urine Drug Y", " ", "n", "", "", "1474", "", "0", "", "804", "", - "804", "", "", "1452", "", "1452", "", "792", "", "792", "Mean", "", - "", "6.5", "", "NA", "", "0.9", "", "0.9", "", "", "6.5", "", "13.1", - "", "0.8", "", "0.8", "SD", "", "", "6.7", "", "NA", "", "1.8", "", - "1.8", "", "", "6.7", "", "13.5", "", "1.8", "", "1.8", "SE", "", "", - "0.2", "", "NA", "", "0.1", "", "0.1", "", "", "0.2", "", "0.4", "", - "0.1", "", "0.1", "CV (%)", "", "", "102.4", "", "NA", "", "210.7", - "", "210.7", "", "", "103.3", "", "103.3", "", "212.4", "", "212.4", - "CV % Geometric Mean", "", "", "NA", "", "NA", "", "NA", "", "NA", "", - "", "NA", "", "NA", "", "NA", "", "NA" - ), - .Dim = c(19L, 7L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) l2 <- basic_table() %>% split_rows_by( @@ -51,19 +33,8 @@ testthat::test_that("PKCT01 is produced correctly", { adpc <- adpc %>% mutate(AVALC = as.factor(AVALC)) result <- build_table(l2, df = adpc) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "A: Drug X", "Plasma Drug X", " ", "Plasma Drug Y", " ", - "Urine Drug X", " ", "Urine Drug Y", " ", "C: Combination", - "Plasma Drug X", " ", "Plasma Drug Y", " ", "Urine Drug X", - " ", "Urine Drug Y", " ", "n_blq", "", "", "402", "", "0", "", - "402", "", "402", "", "", "396", "", "396", "", "396", "", "396" - ), - .Dim = c(19L, 2L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("Specific PKCT01 features are present", { @@ -165,39 +136,6 @@ testthat::test_that("Specific PKCT01 features are present", { testthat::expect_equal(length(pag_works), 11L) # Values are correct - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Cohort/Treatment", " Visit", " Norminal Time from First Dose", "", - "", "A: Drug X", "Day 1", "0", " ", "0.5", " ", "1", " ", "1.5", " ", - "2", " ", "3", " ", "4", " ", "8", " ", "12", " ", "24", " ", "Day 2", - "48", " ", "", "", "", "", "n", "", "", "", "402", "", "134", "", "134", - "", "134", "", "134", "", "134", "", "402", "", "402", "", "402", "", - "402", "", "", "402", "", "", "Number", "of", "s", "", "", "", - "402", "", "0", "", "0", "", "0", "", "0", "", "0", "", "0", "", "0", "", - "0", "", "402", "", "", "402", "", "", "", "", "Mean", "", "", "", "0", - "", "12.6", "", "16.2", "", "15.6", "", "13.4", "", "8.47", "", "4.79", - "", "0.348", "", "0.0224", "", "0", "", "", "0", "", "", "", "", "SD", - "", "", "", "0", "", "1.51", "", "1.63", "", "1.46", "", "1.35", "", - "1.25", "", "1.01", "", "0.179", "", "0.0189", "", "0", "", "", "0", - "", "", "", "", "CV (%) Mean", "", "", "", "NE", "", "12.0", "", - "10.0", "", "9.3", "", "10.1", "", "14.7", "", "21.2", "", "51.6", - "", "84.4", "", "NE", "", "", "NE", "", "", "", "", "Geometric Mean", - "", "", "", "NE", "", "12.5", "", "16.1", "", "15.6", "", "13.4", "", - "8.38", "", "4.69", "", "0.303", "", "0.0156", "", "NE", "", "", "NE", - "", "", "", "", "CV % Geometric Mean", "", "", "", "NE", "", "12.2", "", - "10.1", "", "9.3", "", "10.0", "", "15.0", "", "21.9", "", "58.2", "", - "111.2", "", "NE", "", "", "NE", "", "", "", "", "Median", "", "", "", - "0", "", "12.6", "", "16.2", "", "15.5", "", "13.3", "", "8.4", "", - "4.79", "", "0.318", "", "0.017", "", "0", "", "", "0", "", "", "", - "", "Minimum", "", "", "", "0", "", "9.72", "", "12.6", "", "12.3", - "", "10.8", "", "5.88", "", "2.7", "", "0.076", "", "0.002", "", "0", - "", "", "0", "", "", "", "", "Maximum", "", "", "", "0", "", "15.6", - "", "19.9", "", "19", "", "16.5", "", "10.9", "", "7.09", "", "0.866", - "", "0.083", "", "0", "", "", "0" - ), - .Dim = c(30L, 11L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_pkpt02.R b/tests/testthat/test-table_pkpt02.R new file mode 100644 index 0000000000..5c6b10ef98 --- /dev/null +++ b/tests/testthat/test-table_pkpt02.R @@ -0,0 +1,56 @@ +# Data generation +adpp <- adpp_raw +adpp_plasma <- adpp %>% dplyr::filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1") + +# Define template layout +l <- basic_table() %>% + split_cols_by( + var = "ARMCD", + split_fun = trim_levels_in_group("ARMCD"), + # label_pos = "topleft", # nolint + split_label = "Treatment Arm" + ) %>% + split_rows_by( + var = "PKPARAM", + label_pos = "topleft", + split_label = "PK Parameter" + ) %>% + summarize_vars( + vars = "AVAL", + .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), + .formats = c( + n = "xx.", + mean_sd = sprintf_format("%.3e (%.3e)"), + cv = "xx.x", + geom_mean = sprintf_format("%.3e"), + geom_cv = "xx.x", + median = sprintf_format("%.3e"), + range = sprintf_format("%.3e - %.3e") + ) + ) + +# PKPT02 Drug X +testthat::test_that("PKPT02 is produced correctly for Drug X", { + adpp0 <- adpp_plasma %>% + filter(PPCAT == "Plasma Drug X") %>% + h_pkparam_sort() %>% + mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + + result <- build_table(l, df = adpp0) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) + +# PKPT02 Drug Y +testthat::test_that("PKPT02 is produced correctly for Drug Y", { + adpp1 <- adpp_plasma %>% + filter(PPCAT == "Plasma Drug Y") %>% + h_pkparam_sort() %>% + mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + + result <- build_table(l, df = adpp1) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) diff --git a/tests/testthat/test-table_pkpt02_04_06.R b/tests/testthat/test-table_pkpt02_04_06.R deleted file mode 100644 index 1ed4fb960d..0000000000 --- a/tests/testthat/test-table_pkpt02_04_06.R +++ /dev/null @@ -1,213 +0,0 @@ -# Data generation -adpp <- adpp_raw -adpp_plasma <- adpp %>% dplyr::filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1") -adpp_urine <- adpp %>% dplyr::filter(PPSPEC == "Urine", AVISIT == "CYCLE 1 DAY 1") -adpp_norm_dose <- adpp %>% dplyr::filter( - AVISIT == "CYCLE 1 DAY 1", - stringr::str_detect( - tolower(PARAM), - stringr::regex("norm by dose", ignore_case = TRUE) - ) -) - -# Define template layout -l <- basic_table() %>% - split_cols_by( - var = "ARMCD", - split_fun = trim_levels_in_group("ARMCD"), - # label_pos = "topleft", # nolint - split_label = "Treatment Arm" - ) %>% - split_rows_by( - var = "PKPARAM", - label_pos = "topleft", - split_label = "PK Parameter" - ) %>% - summarize_vars( - vars = "AVAL", - .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), - .formats = c( - n = "xx.", - mean_sd = sprintf_format("%.3e (%.3e)"), - cv = "xx.x", - geom_mean = sprintf_format("%.3e"), - geom_cv = "xx.x", - median = sprintf_format("%.3e"), - range = sprintf_format("%.3e - %.3e") - ) - ) - -# PKPT02 Drug X -testthat::test_that("PKPT02 is produced correctly for Drug X", { - adpp0 <- adpp_plasma %>% - filter(PPCAT == "Plasma Drug X") %>% - h_pkparam_sort() %>% - mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - - result <- build_table(l, df = adpp0) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "PK Parameter", "AUCinf obs (day*ug/mL)", "n", "Mean (SD)", "CV (%)", - "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", - "CL obs (ml/day/kg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", - "CV % Geometric Mean", "Median", "Min - Max", "Cmax (ug/mL)", "n", - "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", - "Min - Max", "ARM A", "", "134", "2.028e+02 (3.766e+01)", "18.6", - "1.994e+02", "18.7", "1.971e+02", "1.253e+02 - 3.110e+02", "", "134", - "5.043e+00 (1.041e+00)", "20.6", "4.929e+00", "22.4", "5.078e+00", - "2.255e+00 - 7.395e+00", "", "134", "3.025e+01 (6.239e+00)", "20.6", - "2.961e+01", "21.0", "2.986e+01", "1.753e+01 - 4.871e+01", "ARM C", "", - "132", "1.955e+02 (3.785e+01)", "19.4", "1.917e+02", "20.1", "1.962e+02", - "1.030e+02 - 3.145e+02", "", "132", "5.009e+00 (9.846e-01)", "19.7", - "4.907e+00", "21.1", "4.969e+00", "2.102e+00 - 7.489e+00", "", "132", - "3.004e+01 (5.457e+00)", "18.2", "2.954e+01", "18.9", "2.977e+01", - "1.585e+01 - 4.757e+01" - ), - .Dim = c(25L, 3L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT02 Drug Y -testthat::test_that("PKPT02 is produced correctly for Drug Y", { - adpp1 <- adpp_plasma %>% - filter(PPCAT == "Plasma Drug Y") %>% - h_pkparam_sort() %>% - mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - - result <- build_table(l, df = adpp1) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "PK Parameter", "AUCinf obs (day*ug/mL)", "n", "Mean (SD)", "CV (%)", - "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", - "CL obs (ml/day/kg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", - "CV % Geometric Mean", "Median", "Min - Max", "Cmax (ug/mL)", "n", - "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", - "Median", "Min - Max", "ARM C", "", "132", "1.986e+02 (3.792e+01)", - "19.1", "1.952e+02", "18.9", "1.953e+02", "1.264e+02 - 3.183e+02", "", - "132", "4.955e+00 (8.951e-01)", "18.1", "4.873e+00", "18.7", "4.936e+00", - "2.987e+00 - 7.211e+00", "", "132", "2.990e+01 (5.550e+00)", "18.6", - "2.935e+01", "20.1", "2.969e+01", "1.406e+01 - 4.345e+01" - ), - .Dim = c(25L, 2L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT04 Drug X -testthat::test_that("PKPT04 is produced correctly for Drug X", { - adpp0 <- adpp_urine %>% - filter(PPCAT == "Plasma Drug X") %>% - h_pkparam_sort() %>% - mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - - result <- build_table(l, df = adpp0) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "PK Parameter", "Ae (mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", - "CV % Geometric Mean", "Median", "Min - Max", "CLR (L/hr)", "n", - "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", - "Min - Max", "Fe (%)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", - "CV % Geometric Mean", "Median", "Min - Max", "RENALCLD (L/hr/mg)", "n", - "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", "Median", - "Min - Max", "ARM A", "", "268", "1.551e+00 (3.385e-01)", "21.8", - "1.513e+00", "23.0", "1.547e+00", "7.021e-01 - 2.464e+00", "", "134", - "4.918e-02 (9.611e-03)", "19.5", "4.818e-02", "21.0", "4.909e-02", - "2.488e-02 - 7.511e-02", "", "268", "1.571e+01 (3.348e+00)", "21.3", - "1.534e+01", "22.2", "1.577e+01", "8.147e+00 - 2.452e+01", "", "134", - "4.873e-03 (9.654e-04)", "19.8", "4.772e-03", "21.2", "4.967e-03", - "2.385e-03 - 7.258e-03", "ARM C", "", "264", "1.535e+00 (2.978e-01)", - "19.4", "1.505e+00", "20.3", "1.547e+00", "8.502e-01 - 2.208e+00", "", - "132", "5.024e-02 (1.050e-02)", "20.9", "4.913e-02", "21.9", "4.984e-02", - "2.505e-02 - 8.560e-02", "", "264", "1.609e+01 (3.103e+00)", "19.3", - "1.578e+01", "20.2", "1.604e+01", "8.503e+00 - 2.443e+01", "", "132", - "5.110e-03 (9.339e-04)", "18.3", "5.019e-03", "19.7", "5.151e-03", - "2.356e-03 - 7.407e-03" - ), - .Dim = c(33L, 3L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT04 Drug Y -testthat::test_that("PKPT04 is produced correctly for Drug Y", { - adpp1 <- adpp_urine %>% - filter(PPCAT == "Plasma Drug Y") %>% - h_pkparam_sort() %>% - mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - - result <- build_table(l, df = adpp1) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "PK Parameter", "Ae (mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", - "CV % Geometric Mean", "Median", "Min - Max", "CLR (L/hr)", "n", - "Mean (SD)", "CV (%)", "Geometric Mean", "CV % Geometric Mean", - "Median", "Min - Max", "Fe (%)", "n", "Mean (SD)", "CV (%)", - "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", - "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", "Geometric Mean", - "CV % Geometric Mean", "Median", "Min - Max", "ARM C", "", "264", - "1.598e+00 (3.154e-01)", "19.7", "1.565e+00", "21.4", "1.603e+00", - "8.574e-01 - 2.257e+00", "", "132", "4.966e-02 (1.009e-02)", "20.3", - "4.857e-02", "22.0", "4.912e-02", "1.839e-02 - 7.761e-02", "", "264", - "1.583e+01 (3.077e+00)", "19.4", "1.552e+01", "20.2", "1.570e+01", - "8.311e+00 - 2.378e+01", "", "132", "5.093e-03 (1.032e-03)", "20.3", - "4.985e-03", "21.4", "5.017e-03", "2.356e-03 - 7.939e-03" - ), - .Dim = c(33L, 2L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT06 Drug X -testthat::test_that("PKPT06 is produced correctly for Drug X", { - adpp0 <- adpp_norm_dose %>% - filter(PPCAT == "Plasma Drug X") %>% - h_pkparam_sort() %>% - mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - - result <- build_table(l, df = adpp0) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "PK Parameter", "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", - "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "ARM A", - "", "134", "4.873e-03 (9.654e-04)", "19.8", "4.772e-03", "21.2", - "4.967e-03", "2.385e-03 - 7.258e-03", "ARM C", "", "132", - "5.110e-03 (9.339e-04)", "18.3", "5.019e-03", "19.7", "5.151e-03", - "2.356e-03 - 7.407e-03" - ), - .Dim = c(9L, 3L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT06 Drug Y -testthat::test_that("PKPT06 is produced correctly for Drug Y", { - adpp1 <- adpp_norm_dose %>% - filter(PPCAT == "Plasma Drug Y") %>% - h_pkparam_sort() %>% - mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - - result <- build_table(l, df = adpp1) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "PK Parameter", "RENALCLD (L/hr/mg)", "n", "Mean (SD)", "CV (%)", - "Geometric Mean", "CV % Geometric Mean", "Median", "Min - Max", "ARM C", - "", "132", "5.093e-03 (1.032e-03)", "20.3", "4.985e-03", "21.4", - "5.017e-03", "2.356e-03 - 7.939e-03" - ), - .Dim = c(9L, 2L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) diff --git a/tests/testthat/test-table_pkpt03.R b/tests/testthat/test-table_pkpt03.R new file mode 100644 index 0000000000..6d737bbc74 --- /dev/null +++ b/tests/testthat/test-table_pkpt03.R @@ -0,0 +1,81 @@ +# Data generation +adpp <- adpp_raw +adpp_plasma <- adpp %>% dplyr::filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1") + +# Helper function +threesigfmt <- function(x, ...) { + as.character(signif(x, 3)) +} + +# Define template layout +l <- basic_table() %>% + split_rows_by( + var = "ARMCD", + split_fun = trim_levels_in_group("ARMCD"), + label_pos = "topleft", + split_label = "Treatment Arm" + ) %>% + split_rows_by( + var = "PKPARAM", + label_pos = "topleft", + split_label = "PK Parameter" + ) %>% + analyze_vars_in_cols( + vars = "AVAL", + .stats = c( + "n", "mean", "sd", "cv", + "geom_mean", "geom_cv", "median", + "min", "max" + ), + .labels = c( + n = "n", + mean = "Mean", + sd = "SD", + cv = "CV (%)", + geom_mean = "Geometric Mean", + geom_cv = "CV % Geometric Mean", + median = "Median", + min = "Minimum", + max = "Maximum" + ), + .formats = c( + n = "xx.", + mean = threesigfmt, + sd = threesigfmt, + cv = "xx.x", + median = threesigfmt, + geom_mean = threesigfmt, + geom_cv = "xx.x", + min = threesigfmt, + max = threesigfmt + ) + ) + +# PKPT03 +testthat::test_that("PKPT03 Drug X is produced correctly", { + # Plasma Drug x + adpp0 <- adpp_plasma %>% + dplyr::filter(PPCAT == "Plasma Drug X") %>% + h_pkparam_sort() %>% + dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + result <- build_table(l, df = adpp0) + main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") + subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) + +testthat::test_that("PKPT03 Drug Y is produced correctly", { + # Plasma Drug Y__ + adpp1 <- adpp_plasma %>% + dplyr::filter(PPCAT == "Plasma Drug Y") %>% + h_pkparam_sort() %>% + dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + result <- build_table(l, df = adpp1) + main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population") + subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT)) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) diff --git a/tests/testthat/test-table_pkpt03_05_07.R b/tests/testthat/test-table_pkpt03_05_07.R deleted file mode 100644 index 06d71684f5..0000000000 --- a/tests/testthat/test-table_pkpt03_05_07.R +++ /dev/null @@ -1,253 +0,0 @@ -# Data generation -adpp <- adpp_raw -adpp_plasma <- adpp %>% dplyr::filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1") -adpp_urine <- adpp %>% dplyr::filter(PPSPEC == "Urine", AVISIT == "CYCLE 1 DAY 1") -adpp_norm_dose <- adpp %>% dplyr::filter( - AVISIT == "CYCLE 1 DAY 1", - stringr::str_detect( - tolower(PARAM), - stringr::regex("norm by dose", ignore_case = TRUE) - ) -) - -# Helper function -threesigfmt <- function(x, ...) { - as.character(signif(x, 3)) -} - -# Define template layout -l <- basic_table() %>% - split_rows_by( - var = "ARMCD", - split_fun = trim_levels_in_group("ARMCD"), - label_pos = "topleft", - split_label = "Treatment Arm" - ) %>% - split_rows_by( - var = "PKPARAM", - label_pos = "topleft", - split_label = "PK Parameter" - ) %>% - analyze_vars_in_cols( - vars = "AVAL", - .stats = c( - "n", "mean", "sd", "cv", - "geom_mean", "geom_cv", "median", - "min", "max" - ), - .labels = c( - n = "n", - mean = "Mean", - sd = "SD", - cv = "CV (%)", - geom_mean = "Geometric Mean", - geom_cv = "CV % Geometric Mean", - median = "Median", - min = "Minimum", - max = "Maximum" - ), - .formats = c( - n = "xx.", - mean = threesigfmt, - sd = threesigfmt, - cv = "xx.x", - median = threesigfmt, - geom_mean = threesigfmt, - geom_cv = "xx.x", - min = threesigfmt, - max = threesigfmt - ) - ) - -# PKPT03 -testthat::test_that("PKPT03 Drug X is produced correctly", { - # Plasma Drug x - adpp0 <- adpp_plasma %>% - dplyr::filter(PPCAT == "Plasma Drug X") %>% - h_pkparam_sort() %>% - dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - result <- build_table(l, df = adpp0) - main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") - subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) - - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Treatment Arm", " PK Parameter", "ARM A", "AUCinf obs (day*ug/mL)", " ", - "CL obs (ml/day/kg)", " ", "Cmax (ug/mL)", " ", "ARM C", - "AUCinf obs (day*ug/mL)", " ", "CL obs (ml/day/kg)", " ", "Cmax (ug/mL)", - " ", "", "n", "", "", "134", "", "134", "", "134", "", "", "132", "", - "132", "", "132", "", "Mean", "", "", "203", "", "5.04", "", "30.2", "", - "", "195", "", "5.01", "", "30", "", "SD", "", "", "37.7", "", "1.04", "", - "6.24", "", "", "37.8", "", "0.985", "", "5.46", "", "CV (%)", "", "", - "18.6", "", "20.6", "", "20.6", "", "", "19.4", "", "19.7", "", "18.2", - "", "Geometric Mean", "", "", "199", "", "4.93", "", "29.6", "", "", - "192", "", "4.91", "", "29.5", "", "CV % Geometric Mean", "", "", "18.7", - "", "22.4", "", "21.0", "", "", "20.1", "", "21.1", "", "18.9", "", - "Median", "", "", "197", "", "5.08", "", "29.9", "", "", "196", "", - "4.97", "", "29.8", "", "Minimum", "", "", "125", "", "2.25", "", "17.5", - "", "", "103", "", "2.1", "", "15.9", "", "Maximum", "", "", "311", "", - "7.39", "", "48.7", "", "", "315", "", "7.49", "", "47.6" - ), - .Dim = c(16L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -testthat::test_that("PKPT03 Drug Y is produced correctly", { - # Plasma Drug Y__ - adpp1 <- adpp_plasma %>% - dplyr::filter(PPCAT == "Plasma Drug Y") %>% - h_pkparam_sort() %>% - dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - result <- build_table(l, df = adpp1) - main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population") - subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT)) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "Treatment Arm", " PK Parameter", "ARM C", "AUCinf obs (day*ug/mL)", " ", - "CL obs (ml/day/kg)", " ", "Cmax (ug/mL)", " ", "", "n", "", "", "132", "", - "132", "", "132", "", "Mean", "", "", "199", "", "4.96", "", "29.9", "", - "SD", "", "", "37.9", "", "0.895", "", "5.55", "", "CV (%)", "", "", - "19.1", "", "18.1", "", "18.6", "", "Geometric Mean", "", "", "195", "", - "4.87", "", "29.4", "", "CV % Geometric Mean", "", "", "18.9", "", "18.7", - "", "20.1", "", "Median", "", "", "195", "", "4.94", "", "29.7", "", - "Minimum", "", "", "126", "", "2.99", "", "14.1", "", "Maximum", "", "", - "318", "", "7.21", "", "43.4" - ), - .Dim = c(9L, 10L) - ) - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT05 Drug X -testthat::test_that("PKPT05 Drug X is produced correctly", { - adpp0 <- adpp_urine %>% - dplyr::filter(PPCAT == "Plasma Drug X") %>% - h_pkparam_sort() %>% - dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - result <- build_table(l, df = adpp0) - main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") - subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) - - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Treatment Arm", " PK Parameter", "ARM A", "Ae (mg)", " ", "CLR (L/hr)", - " ", "Fe (%)", " ", "RENALCLD (L/hr/mg)", " ", "ARM C", "Ae (mg)", " ", - "CLR (L/hr)", " ", "Fe (%)", " ", "RENALCLD (L/hr/mg)", " ", "", "n", "", - "", "268", "", "134", "", "268", "", "134", "", "", "264", "", "132", "", - "264", "", "132", "", "Mean", "", "", "1.55", "", "0.0492", "", "15.7", "", - "0.00487", "", "", "1.54", "", "0.0502", "", "16.1", "", "0.00511", "", - "SD", "", "", "0.338", "", "0.00961", "", "3.35", "", "0.000965", "", - "", "0.298", "", "0.0105", "", "3.1", "", "0.000934", "", "CV (%)", "", - "", "21.8", "", "19.5", "", "21.3", "", "19.8", "", "", "19.4", "", - "20.9", "", "19.3", "", "18.3", "", "Geometric Mean", "", "", "1.51", - "", "0.0482", "", "15.3", "", "0.00477", "", "", "1.51", "", "0.0491", - "", "15.8", "", "0.00502", "", "CV % Geometric Mean", "", "", "23.0", - "", "21.0", "", "22.2", "", "21.2", "", "", "20.3", "", "21.9", "", "20.2", - "", "19.7", "", "Median", "", "", "1.55", "", "0.0491", "", "15.8", "", - "0.00497", "", "", "1.55", "", "0.0498", "", "16", "", "0.00515", "", - "Minimum", "", "", "0.702", "", "0.0249", "", "8.15", "", "0.00238", "", - "", "0.85", "", "0.0251", "", "8.5", "", "0.00236", "", "Maximum", "", "", - "2.46", "", "0.0751", "", "24.5", "", "0.00726", "", "", "2.21", "", - "0.0856", "", "24.4", "", "0.00741" - ), - .Dim = c(20L, 10L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT05 Drug Y -testthat::test_that("PKPT05 Drug Y is produced correctly", { - # Plasma Drug Y - adpp1 <- adpp_urine %>% - dplyr::filter(PPCAT == "Plasma Drug Y") %>% - h_pkparam_sort() %>% - dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - result <- build_table(l, df = adpp1) - main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population") - subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT)) - - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Treatment Arm", " PK Parameter", "ARM C", "Ae (mg)", " ", "CLR (L/hr)", - " ", "Fe (%)", " ", "RENALCLD (L/hr/mg)", " ", "", "n", "", "", "264", "", - "132", "", "264", "", "132", "", "Mean", "", "", "1.6", "", "0.0497", - "", "15.8", "", "0.00509", "", "SD", "", "", "0.315", "", "0.0101", "", - "3.08", "", "0.00103", "", "CV (%)", "", "", "19.7", "", "20.3", "", - "19.4", "", "20.3", "", "Geometric Mean", "", "", "1.56", "", "0.0486", - "", "15.5", "", "0.00499", "", "CV % Geometric Mean", "", "", "21.4", - "", "22.0", "", "20.2", "", "21.4", "", "Median", "", "", "1.6", "", - "0.0491", "", "15.7", "", "0.00502", "", "Minimum", "", "", "0.857", - "", "0.0184", "", "8.31", "", "0.00236", "", "Maximum", "", "", "2.26", - "", "0.0776", "", "23.8", "", "0.00794" - ), - .Dim = c(11L, 10L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT07 Drug X -testthat::test_that("PKPT07 Drug X is produced correctly", { - # Plasma Drug X__ - adpp0 <- adpp_norm_dose %>% - dplyr::filter(PPCAT == "Plasma Drug X") %>% - h_pkparam_sort() %>% - dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - result <- build_table(l, df = adpp0) - main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") - subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) - - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Treatment Arm", " PK Parameter", "ARM A", "RENALCLD (L/hr/mg)", " ", - "ARM C", "RENALCLD (L/hr/mg)", " ", "", "n", "", "", "134", "", "", "132", - "", "Mean", "", "", "0.00487", "", "", "0.00511", "", "SD", "", "", - "0.000965", "", "", "0.000934", "", "CV (%)", "", "", "19.8", "", "", - "18.3", "", "Geometric Mean", "", "", "0.00477", "", "", "0.00502", "", - "CV % Geometric Mean", "", "", "21.2", "", "", "19.7", "", "Median", "", - "", "0.00497", "", "", "0.00515", "", "Minimum", "", "", "0.00238", "", - "", "0.00236", "", "Maximum", "", "", "0.00726", "", "", "0.00741" - ), - .Dim = c(8L, 10L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) -}) - -# PKPT07 Drug Y -testthat::test_that("PKPT07 Drug Y is produced correctly", { - # Plasma Drug Y - adpp1 <- adpp_norm_dose %>% - dplyr::filter(PPCAT == "Plasma Drug Y") %>% - h_pkparam_sort() %>% - dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) - result <- build_table(l, df = adpp1) - main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population") - subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT)) - - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "Treatment Arm", " PK Parameter", "ARM C", "RENALCLD (L/hr/mg)", " ", - "", "n", "", "", "132", "", "Mean", "", "", "0.00509", "", "SD", "", "", - "0.00103", "", "CV (%)", "", "", "20.3", "", "Geometric Mean", "", "", - "0.00499", "", "CV % Geometric Mean", "", "", "21.4", "", "Median", "", - "", "0.00502", "", "Minimum", "", "", "0.00236", "", "Maximum", "", - "", "0.00794" - ), - .Dim = c(5L, 10L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) -}) diff --git a/tests/testthat/test-table_pkpt04.R b/tests/testthat/test-table_pkpt04.R new file mode 100644 index 0000000000..7810371e4f --- /dev/null +++ b/tests/testthat/test-table_pkpt04.R @@ -0,0 +1,56 @@ +# Data generation +adpp <- adpp_raw +adpp_urine <- adpp %>% dplyr::filter(PPSPEC == "Urine", AVISIT == "CYCLE 1 DAY 1") + +# Define template layout +l <- basic_table() %>% + split_cols_by( + var = "ARMCD", + split_fun = trim_levels_in_group("ARMCD"), + # label_pos = "topleft", # nolint + split_label = "Treatment Arm" + ) %>% + split_rows_by( + var = "PKPARAM", + label_pos = "topleft", + split_label = "PK Parameter" + ) %>% + summarize_vars( + vars = "AVAL", + .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), + .formats = c( + n = "xx.", + mean_sd = sprintf_format("%.3e (%.3e)"), + cv = "xx.x", + geom_mean = sprintf_format("%.3e"), + geom_cv = "xx.x", + median = sprintf_format("%.3e"), + range = sprintf_format("%.3e - %.3e") + ) + ) + +# PKPT04 Drug X +testthat::test_that("PKPT04 is produced correctly for Drug X", { + adpp0 <- adpp_urine %>% + filter(PPCAT == "Plasma Drug X") %>% + h_pkparam_sort() %>% + mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + + result <- build_table(l, df = adpp0) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) + +# PKPT04 Drug Y +testthat::test_that("PKPT04 is produced correctly for Drug Y", { + adpp1 <- adpp_urine %>% + filter(PPCAT == "Plasma Drug Y") %>% + h_pkparam_sort() %>% + mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + + result <- build_table(l, df = adpp1) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) diff --git a/tests/testthat/test-table_pkpt05.R b/tests/testthat/test-table_pkpt05.R new file mode 100644 index 0000000000..fdd9b5ac79 --- /dev/null +++ b/tests/testthat/test-table_pkpt05.R @@ -0,0 +1,81 @@ +# Data generation +adpp <- adpp_raw +adpp_urine <- adpp %>% dplyr::filter(PPSPEC == "Urine", AVISIT == "CYCLE 1 DAY 1") + +# Helper function +threesigfmt <- function(x, ...) { + as.character(signif(x, 3)) +} + +# Define template layout +l <- basic_table() %>% + split_rows_by( + var = "ARMCD", + split_fun = trim_levels_in_group("ARMCD"), + label_pos = "topleft", + split_label = "Treatment Arm" + ) %>% + split_rows_by( + var = "PKPARAM", + label_pos = "topleft", + split_label = "PK Parameter" + ) %>% + analyze_vars_in_cols( + vars = "AVAL", + .stats = c( + "n", "mean", "sd", "cv", + "geom_mean", "geom_cv", "median", + "min", "max" + ), + .labels = c( + n = "n", + mean = "Mean", + sd = "SD", + cv = "CV (%)", + geom_mean = "Geometric Mean", + geom_cv = "CV % Geometric Mean", + median = "Median", + min = "Minimum", + max = "Maximum" + ), + .formats = c( + n = "xx.", + mean = threesigfmt, + sd = threesigfmt, + cv = "xx.x", + median = threesigfmt, + geom_mean = threesigfmt, + geom_cv = "xx.x", + min = threesigfmt, + max = threesigfmt + ) + ) + +# PKPT05 Drug X +testthat::test_that("PKPT05 Drug X is produced correctly", { + adpp0 <- adpp_urine %>% + dplyr::filter(PPCAT == "Plasma Drug X") %>% + h_pkparam_sort() %>% + dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + result <- build_table(l, df = adpp0) + main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") + subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) + +# PKPT05 Drug Y +testthat::test_that("PKPT05 Drug Y is produced correctly", { + # Plasma Drug Y + adpp1 <- adpp_urine %>% + dplyr::filter(PPCAT == "Plasma Drug Y") %>% + h_pkparam_sort() %>% + dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + result <- build_table(l, df = adpp1) + main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population") + subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT)) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) diff --git a/tests/testthat/test-table_pkpt06.R b/tests/testthat/test-table_pkpt06.R new file mode 100644 index 0000000000..7520db4bbb --- /dev/null +++ b/tests/testthat/test-table_pkpt06.R @@ -0,0 +1,62 @@ +# Data generation +adpp <- adpp_raw +adpp_norm_dose <- adpp %>% dplyr::filter( + AVISIT == "CYCLE 1 DAY 1", + stringr::str_detect( + tolower(PARAM), + stringr::regex("norm by dose", ignore_case = TRUE) + ) +) + +# Define template layout +l <- basic_table() %>% + split_cols_by( + var = "ARMCD", + split_fun = trim_levels_in_group("ARMCD"), + # label_pos = "topleft", # nolint + split_label = "Treatment Arm" + ) %>% + split_rows_by( + var = "PKPARAM", + label_pos = "topleft", + split_label = "PK Parameter" + ) %>% + summarize_vars( + vars = "AVAL", + .stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"), + .formats = c( + n = "xx.", + mean_sd = sprintf_format("%.3e (%.3e)"), + cv = "xx.x", + geom_mean = sprintf_format("%.3e"), + geom_cv = "xx.x", + median = sprintf_format("%.3e"), + range = sprintf_format("%.3e - %.3e") + ) + ) + +# PKPT06 Drug X +testthat::test_that("PKPT06 is produced correctly for Drug X", { + adpp0 <- adpp_norm_dose %>% + filter(PPCAT == "Plasma Drug X") %>% + h_pkparam_sort() %>% + mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + + result <- build_table(l, df = adpp0) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) + +# PKPT06 Drug Y +testthat::test_that("PKPT06 is produced correctly for Drug Y", { + adpp1 <- adpp_norm_dose %>% + filter(PPCAT == "Plasma Drug Y") %>% + h_pkparam_sort() %>% + mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + + result <- build_table(l, df = adpp1) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) diff --git a/tests/testthat/test-table_pkpt07.R b/tests/testthat/test-table_pkpt07.R new file mode 100644 index 0000000000..2289efd1c6 --- /dev/null +++ b/tests/testthat/test-table_pkpt07.R @@ -0,0 +1,88 @@ +# Data generation +adpp <- adpp_raw +adpp_norm_dose <- adpp %>% dplyr::filter( + AVISIT == "CYCLE 1 DAY 1", + stringr::str_detect( + tolower(PARAM), + stringr::regex("norm by dose", ignore_case = TRUE) + ) +) + +# Helper function +threesigfmt <- function(x, ...) { + as.character(signif(x, 3)) +} + +# Define template layout +l <- basic_table() %>% + split_rows_by( + var = "ARMCD", + split_fun = trim_levels_in_group("ARMCD"), + label_pos = "topleft", + split_label = "Treatment Arm" + ) %>% + split_rows_by( + var = "PKPARAM", + label_pos = "topleft", + split_label = "PK Parameter" + ) %>% + analyze_vars_in_cols( + vars = "AVAL", + .stats = c( + "n", "mean", "sd", "cv", + "geom_mean", "geom_cv", "median", + "min", "max" + ), + .labels = c( + n = "n", + mean = "Mean", + sd = "SD", + cv = "CV (%)", + geom_mean = "Geometric Mean", + geom_cv = "CV % Geometric Mean", + median = "Median", + min = "Minimum", + max = "Maximum" + ), + .formats = c( + n = "xx.", + mean = threesigfmt, + sd = threesigfmt, + cv = "xx.x", + median = threesigfmt, + geom_mean = threesigfmt, + geom_cv = "xx.x", + min = threesigfmt, + max = threesigfmt + ) + ) + +# PKPT07 Drug X +testthat::test_that("PKPT07 Drug X is produced correctly", { + # Plasma Drug X__ + adpp0 <- adpp_norm_dose %>% + dplyr::filter(PPCAT == "Plasma Drug X") %>% + h_pkparam_sort() %>% + dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + result <- build_table(l, df = adpp0) + main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population") + subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT)) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) + +# PKPT07 Drug Y +testthat::test_that("PKPT07 Drug Y is produced correctly", { + # Plasma Drug Y + adpp1 <- adpp_norm_dose %>% + dplyr::filter(PPCAT == "Plasma Drug Y") %>% + h_pkparam_sort() %>% + dplyr::mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) + result <- build_table(l, df = adpp1) + main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population") + subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT)) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) +}) diff --git a/tests/testthat/test-table_rspt01.R b/tests/testthat/test-table_rspt01.R index b2f61d6dc2..5bc5c88bea 100644 --- a/tests/testthat/test-table_rspt01.R +++ b/tests/testthat/test-table_rspt01.R @@ -42,32 +42,8 @@ testthat::test_that("RSPT01: 1. Best Overall Response", { result <- build_table(l, adrs) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Responders", "95% CI (Wald, with correction)", - "Unstratified Analysis", "Difference in Response rate (%)", "95% CI (Wald, with correction)", - "p-value (Chi-Squared Test with Schouten Correction)", "Odds Ratio (95% CI)", - "Complete Response (CR)", "95% CI (Wald, with correction)", "Partial Response (PR)", - "95% CI (Wald, with correction)", "Stable Disease (SD)", "95% CI (Wald, with correction)", - "Progressive Disease (PD)", "95% CI (Wald, with correction)", - "Not Evaluable (NE)", "95% CI (Wald, with correction)", "ARM A", - "(N=134)", "100 (74.6%)", "(66.9, 82.4)", "", "", "", "", "", - "60 (44.8%)", "(35.98, 53.57)", "40 (29.9%)", "(21.73, 37.97)", - "9 (6.7%)", "(2.11, 11.33)", "24 (17.9%)", "(11.05, 24.78)", - "1 (0.7%)", "(0.00, 2.58)", "ARM B", "(N=134)", "84 (62.7%)", "(54.1, 71.2)", - "", "-11.9", "(-23.7, -0.2)", "0.0416", "0.57 (0.34 - 0.96)", - "47 (35.1%)", "(26.62, 43.53)", "37 (27.6%)", "(19.67, 35.55)", - "22 (16.4%)", "(9.77, 23.06)", "16 (11.9%)", "(6.08, 17.80)", - "12 (9.0%)", "(3.75, 14.16)", "ARM C", "(N=132)", "81 (61.4%)", - "(52.7, 70.0)", "", "-13.3", "(-25.1, -1.4)", "0.0245", "0.54 (0.32 - 0.91)", - "57 (43.2%)", "(34.35, 52.01)", "24 (18.2%)", "(11.22, 25.14)", - "13 (9.8%)", "(4.39, 15.31)", "33 (25.0%)", "(17.23, 32.77)", "5 (3.8%)", - "(0.15, 7.42)" - ), - .Dim = c(19L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("RSPT01: 2. Best Overall Response (selecting sections to display)", { @@ -93,30 +69,8 @@ testthat::test_that("RSPT01: 2. Best Overall Response (selecting sections to dis result <- build_table(l, adrs) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Responders", "95% CI (Wald, with correction)", - "Unstratified Analysis", "Difference in Response rate (%)", "95% CI (Wald, with correction)", - "p-value (Chi-Squared Test with Schouten Correction)", "Complete Response (CR)", - "95% CI (Wald, with correction)", "Partial Response (PR)", "95% CI (Wald, with correction)", - "Stable Disease (SD)", "95% CI (Wald, with correction)", "Progressive Disease (PD)", - "95% CI (Wald, with correction)", "Not Evaluable (NE)", "95% CI (Wald, with correction)", - "ARM A", "(N=134)", "100 (74.6%)", "(66.9, 82.4)", "", "", "", - "", "60 (44.8%)", "(35.98, 53.57)", "40 (29.9%)", "(21.73, 37.97)", - "9 (6.7%)", "(2.11, 11.33)", "24 (17.9%)", "(11.05, 24.78)", - "1 (0.7%)", "(0.00, 2.58)", "ARM B", "(N=134)", "84 (62.7%)", "(54.1, 71.2)", - "", "-11.9", "(-23.7, -0.2)", "0.0416", "47 (35.1%)", "(26.62, 43.53)", - "37 (27.6%)", "(19.67, 35.55)", "22 (16.4%)", "(9.77, 23.06)", - "16 (11.9%)", "(6.08, 17.80)", "12 (9.0%)", "(3.75, 14.16)", "ARM C", - "(N=132)", "81 (61.4%)", "(52.7, 70.0)", "", "-13.3", "(-25.1, -1.4)", - "0.0245", "57 (43.2%)", "(34.35, 52.01)", "24 (18.2%)", "(11.22, 25.14)", - "13 (9.8%)", "(4.39, 15.31)", "33 (25.0%)", "(17.23, 32.77)", "5 (3.8%)", - "(0.15, 7.42)" - ), - .Dim = c(18L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("RSPT01: 3. Best Overall Response (modifying settings)", { @@ -158,31 +112,8 @@ testthat::test_that("RSPT01: 3. Best Overall Response (modifying settings)", { result <- build_table(l, adrs) result <- result[-nrow(result), ] - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Responders", "90% CI (Clopper-Pearson)", - "Unstratified Analysis", "Difference in Response rate (%)", "90% CI (Anderson-Hauck)", - "p-value (Fisher's Exact Test)", "Odds Ratio (90% CI)", "Complete Response (CR)", - "90% CI (Clopper-Pearson)", "Partial Response (PR)", "90% CI (Clopper-Pearson)", - "Stable Disease (SD)", "90% CI (Clopper-Pearson)", "Progressive Disease (PD)", - "90% CI (Clopper-Pearson)", "Not Evaluable (NE)", "ARM A", "(N=134)", - "100 (74.6%)", "(67.7, 80.7)", "", "", "", "", "", "60 (44.8%)", - "(37.48, 52.25)", "40 (29.9%)", "(23.36, 37.02)", "9 (6.7%)", - "(3.55, 11.43)", "24 (17.9%)", "(12.67, 24.25)", "1 (0.7%)", - "ARM B", "(N=134)", "84 (62.7%)", "(55.3, 69.7)", "", "-11.9", - "(-21.6, -2.3)", "0.0479", "0.57 (0.37 - 0.89)", "47 (35.1%)", - "(28.22, 42.43)", "37 (27.6%)", "(21.31, 34.67)", "22 (16.4%)", - "(11.38, 22.61)", "16 (11.9%)", "(7.63, 17.57)", "12 (9.0%)", "ARM C", - "(N=132)", "81 (61.4%)", "(53.9, 68.5)", "", "-13.3", "(-23.0, -3.5)", - "0.0253", "0.54 (0.35 - 0.84)", "57 (43.2%)", "(35.88, 50.71)", - "24 (18.2%)", "(12.87, 24.61)", "13 (9.8%)", "(5.92, 15.20)", - "33 (25.0%)", "(18.90, 31.97)", "5 (3.8%)" - ), - .Dim = c(18L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("RSPT01: 4. Best Overall Response (with stratified analysis)", { @@ -230,36 +161,9 @@ testthat::test_that("RSPT01: 4. Best Overall Response (with stratified analysis) estimate_multinomial_response(var = "AVALC") result <- build_table(l, adrs) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Responders", "95% CI (Wald, with correction)", - "Unstratified Analysis", "Difference in Response rate (%)", "95% CI (Wald, with correction)", - "p-value (Chi-Squared Test with Schouten Correction)", "Odds Ratio (95% CI)", - "Stratified Analysis", "Difference in Response rate (%)", "95% CI (CMH, without correction)", - "p-value (Cochran-Mantel-Haenszel Test)", "Odds Ratio (95% CI)", - "Complete Response (CR)", "95% CI (Wald, with correction)", "Partial Response (PR)", - "95% CI (Wald, with correction)", "Stable Disease (SD)", "95% CI (Wald, with correction)", - "Progressive Disease (PD)", "95% CI (Wald, with correction)", - "Not Evaluable (NE)", "95% CI (Wald, with correction)", "ARM A", - "(N=134)", "100 (74.6%)", "(66.9, 82.4)", "", "", "", "", "", - "", "", "", "", "", "60 (44.8%)", "(35.98, 53.57)", "40 (29.9%)", - "(21.73, 37.97)", "9 (6.7%)", "(2.11, 11.33)", "24 (17.9%)", - "(11.05, 24.78)", "1 (0.7%)", "(0.00, 2.58)", "ARM B", "(N=134)", - "84 (62.7%)", "(54.1, 71.2)", "", "-11.9", "(-23.7, -0.2)", "0.0416", - "0.57 (0.34 - 0.96)", "", "-11.9", "(-22.7, -1.0)", "0.0366", "0.57 (0.34 - 0.96)", - "47 (35.1%)", "(26.62, 43.53)", "37 (27.6%)", "(19.67, 35.55)", - "22 (16.4%)", "(9.77, 23.06)", "16 (11.9%)", "(6.08, 17.80)", - "12 (9.0%)", "(3.75, 14.16)", "ARM C", "(N=132)", "81 (61.4%)", - "(52.7, 70.0)", "", "-13.3", "(-25.1, -1.4)", "0.0245", "0.54 (0.32 - 0.91)", - "", "-13.5", "(-24.5, -2.5)", "0.0180", "0.54 (0.32 - 0.90)", - "57 (43.2%)", "(34.35, 52.01)", "24 (18.2%)", "(11.22, 25.14)", - "13 (9.8%)", "(4.39, 15.31)", "33 (25.0%)", "(17.23, 32.77)", "5 (3.8%)", - "(0.15, 7.42)" - ), - .Dim = c(24L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("RSPT01: 5. Best Overall Response (modifying the definition of overall response)", { @@ -289,31 +193,9 @@ testthat::test_that("RSPT01: 5. Best Overall Response (modifying the definition adrs$is_rsp <- adrs$AVALC == "Complete Response (CR)" result <- build_table(l, adrs) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Responders", "95% CI (Wald, with correction)", - "Unstratified Analysis", "Difference in Response rate (%)", "95% CI (Wald, with correction)", - "p-value (Chi-Squared Test with Schouten Correction)", "Odds Ratio (95% CI)", - "Complete Response (CR)", "95% CI (Wald, with correction)", "Partial Response (PR)", - "95% CI (Wald, with correction)", "Stable Disease (SD)", "95% CI (Wald, with correction)", - "Progressive Disease (PD)", "95% CI (Wald, with correction)", - "Not Evaluable (NE)", "95% CI (Wald, with correction)", "ARM A", - "(N=134)", "60 (44.8%)", "(36.0, 53.6)", "", "", "", "", "", "60 (44.8%)", - "(35.98, 53.57)", "40 (29.9%)", "(21.73, 37.97)", "9 (6.7%)", - "(2.11, 11.33)", "24 (17.9%)", "(11.05, 24.78)", "1 (0.7%)", - "(0.00, 2.58)", "ARM B", "(N=134)", "47 (35.1%)", "(26.6, 43.5)", - "", "-9.7", "(-22.1, 2.7)", "0.1197", "0.67 (0.41 - 1.09)", "47 (35.1%)", - "(26.62, 43.53)", "37 (27.6%)", "(19.67, 35.55)", "22 (16.4%)", - "(9.77, 23.06)", "16 (11.9%)", "(6.08, 17.80)", "12 (9.0%)", "(3.75, 14.16)", - "ARM C", "(N=132)", "57 (43.2%)", "(34.4, 52.0)", "", "-1.6", "(-14.3, 11.1)", - "0.8413", "0.94 (0.58 - 1.52)", "57 (43.2%)", "(34.35, 52.01)", - "24 (18.2%)", "(11.22, 25.14)", "13 (9.8%)", "(4.39, 15.31)", - "33 (25.0%)", "(17.23, 32.77)", "5 (3.8%)", "(0.15, 7.42)" - ), - .Dim = c(19L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) @@ -361,25 +243,7 @@ testthat::test_that("RSPT01: 6. Best Overall Response (define new sections to di estimate_multinomial_response(var = "AVALC_NEW") result <- build_table(l, adrs) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Responders", "95% CI (Wald, with correction)", - "Unstratified Analysis", "Difference in Response rate (%)", "95% CI (Wald, with correction)", - "p-value (Chi-Squared Test with Schouten Correction)", "Odds Ratio (95% CI)", - "No Progression", "95% CI (Wald, with correction)", "Progressive Disease (PD)", - "95% CI (Wald, with correction)", "Not Evaluable (NE)", "95% CI (Wald, with correction)", - "ARM A", "(N=134)", "100 (74.6%)", "(66.9, 82.4)", "", "", "", - "", "", "109 (81.3%)", "(74.37, 88.31)", "24 (17.9%)", "(11.05, 24.78)", - "1 (0.7%)", "(0.00, 2.58)", "ARM B", "(N=134)", "84 (62.7%)", "(54.1, 71.2)", - "", "-11.9", "(-23.7, -0.2)", "0.0416", "0.57 (0.34 - 0.96)", - "106 (79.1%)", "(71.85, 86.36)", "16 (11.9%)", "(6.08, 17.80)", - "12 (9.0%)", "(3.75, 14.16)", "ARM C", "(N=132)", "81 (61.4%)", - "(52.7, 70.0)", "", "-13.3", "(-25.1, -1.4)", "0.0245", "0.54 (0.32 - 0.91)", - "94 (71.2%)", "(63.11, 79.31)", "33 (25.0%)", "(17.23, 32.77)", - "5 (3.8%)", "(0.15, 7.42)" - ), - .Dim = c(15L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_ttet01.R b/tests/testthat/test-table_ttet01.R index c9a80c69b1..87c5b4e08b 100644 --- a/tests/testthat/test-table_ttet01.R +++ b/tests/testthat/test-table_ttet01.R @@ -74,36 +74,9 @@ testthat::test_that("TTET01 default variant is produced correctly", { ) result <- build_table(l, df = adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Patients with event (%)", "Earliest contributing event", "Death", - "Patients without event (%)", "Time to Event (Months)", "Median", "95% CI", - "25% and 75%-ile", "Range (censored)", "Range (event)", - "Unstratified Analysis", "p-value (log-rank)", "Hazard Ratio", "95% CI", - "6 Months", "Patients remaining at risk", "Event Free Rate (%)", "95% CI", - "Difference in Event Free Rate", "95% CI", "p-value (Z-test)", "12 Months", - "Patients remaining at risk", "Event Free Rate (%)", "95% CI", - "Difference in Event Free Rate", "95% CI", "p-value (Z-test)", "A: Drug X", - "(N=134)", "79 (59%)", "", "79", "55 (41%)", "", "41.4", "(27.7, 54.7)", - "15.4, 75.2", "0.4 to 154.7", "0.3 to 116.4", "", "", "", "", "", "106", - "83.83", "(77.49, 90.17)", "", "", "", "", "92", "78.03", "(70.82, 85.24)", - "", "", "", "B: Placebo", "(N=134)", "87 (64.9%)", "", "87", "47 (35.1%)", - "", "27.5", "(17.3, 30.2)", "9.5, 54.9", "0.9 to 91.0", "0.0 to 122.4", "", - "0.0334", "1.39", "(1.03, 1.90)", "", "112", "89.16", "(83.80, 94.53)", - "5.33", "(-2.97, 13.64)", "0.2080", "", "83", "70.32", "(62.27, 78.37)", - "-7.71", "(-18.51, 3.10)", "0.1622", "C: Combination", "(N=132)", - "116 (87.9%)", "", "116", "16 (12.1%)", "", "11.1", "(9.6, 15.9)", - "5.3, 25.2", "0.3 to 49.4", "0.1 to 101.6", "", "<0.0001", "2.75", - "(2.05, 3.70)", "", "92", "73.40", "(65.72, 81.07)", "-10.43", - "(-20.38, -0.48)", "0.0399", "", "56", "46.39", "(37.59, 55.18)", "-31.64", - "(-43.01, -20.26)", "<0.0001" - ), - .Dim = c(30L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("TTET01 variant 2: selecting sections to display", { @@ -146,28 +119,9 @@ testthat::test_that("TTET01 variant 2: selecting sections to display", { time_point = c(12) ) result <- build_table(l, df = adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Patients with event (%)", "Patients without event (%)", - "Time to Event (Months)", "Median", "95% CI", "25% and 75%-ile", - "Range (censored)", "Range (event)", "Unstratified Analysis", - "p-value (log-rank)", "Hazard Ratio", "95% CI", "12 Months", - "Patients remaining at risk", "Event Free Rate (%)", "95% CI", - "A: Drug X", "(N=134)", "79 (59%)", "55 (41%)", "", "41.4", "(27.7, 54.7)", - "15.4, 75.2", "0.4 to 154.7", "0.3 to 116.4", "", "", "", "", "", "92", - "78.03", "(70.82, 85.24)", "B: Placebo", "(N=134)", "87 (64.9%)", - "47 (35.1%)", "", "27.5", "(17.3, 30.2)", "9.5, 54.9", "0.9 to 91.0", - "0.0 to 122.4", "", "0.0334", "1.39", "(1.03, 1.90)", "", "83", "70.32", - "(62.27, 78.37)", "C: Combination", "(N=132)", "116 (87.9%)", "16 (12.1%)", - "", "11.1", "(9.6, 15.9)", "5.3, 25.2", "0.3 to 49.4", "0.1 to 101.6", "", - "<0.0001", "2.75", "(2.05, 3.70)", "", "56", "46.39", "(37.59, 55.18)" - ), - .Dim = c(18L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("TTET01 variant 3: modifying analysis details like conftype, ties, alpha level", { @@ -231,31 +185,9 @@ testthat::test_that("TTET01 variant 3: modifying analysis details like conftype, table_names_suffix = "_975_pct" ) result <- build_table(l, df = adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Patients with event (%)", "Earliest contributing event", "Death", - "Patients without event (%)", "Time to Event (Months)", "Median", "90% CI", - "25% and 75%-ile", "Range (censored)", "Range (event)", - "Unstratified Analysis", "p-value (log-rank)", "Hazard Ratio", "95% CI", - "12 Months", "Patients remaining at risk", "Event Free Rate (%)", "90% CI", - "Difference in Event Free Rate", "97.5% CI", "p-value (Z-test)", "A: Drug X", - "(N=134)", "79 (59%)", "", "79", "55 (41%)", "", "41.4", "(27.9, 54.1)", - "15.4, 75.2", "0.4 to 154.7", "0.3 to 116.4", "", "", "", "", "", "92", - "78.03", "(71.24, 83.40)", "", "", "", "B: Placebo", "(N=134)", "87 (64.9%)", - "", "87", "47 (35.1%)", "", "27.5", "(18.8, 29.9)", "9.5, 54.9", "0.9 to 91.0", - "0.0 to 122.4", "", "0.0334", "1.39", "(1.03, 1.90)", "", "83", "70.32", - "(62.97, 76.49)", "-7.71", "(-20.07, 4.65)", "0.1622", "C: Combination", - "(N=132)", "116 (87.9%)", "", "116", "16 (12.1%)", "", "11.1", "(9.7, 15.1)", - "5.3, 25.2", "0.3 to 49.4", "0.1 to 101.6", "", "<0.0001", "2.75", - "(2.05, 3.70)", "", "56", "46.39", "(38.87, 53.56)", "-31.64", - "(-44.64, -18.63)", "<0.0001" - ), - .Dim = c(23L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("TTET01 variant 4: with stratified analysis", { @@ -314,33 +246,9 @@ testthat::test_that("TTET01 variant 4: with stratified analysis", { time_point = 12 ) result <- build_table(l, df = adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Patients with event (%)", "Earliest contributing event", "Death", - "Patients without event (%)", "Time to Event (Months)", "Median", "95% CI", - "25% and 75%-ile", "Range (censored)", "Range (event)", - "Unstratified Analysis", "p-value (log-rank)", "Hazard Ratio", "95% CI", - "Stratified Analysis", "p-value (log-rank)", "Hazard Ratio", "95% CI", - "12 Months", "Patients remaining at risk", "Event Free Rate (%)", "95% CI", - "Difference in Event Free Rate", "95% CI", "p-value (Z-test)", "A: Drug X", - "(N=134)", "79 (59%)", "", "79", "55 (41%)", "", "41.4", "(27.7, 54.7)", - "15.4, 75.2", "0.4 to 154.7", "0.3 to 116.4", "", "", "", "", "", "", "", - "", "", "92", "78.03", "(70.82, 85.24)", "", "", "", "B: Placebo", "(N=134)", - "87 (64.9%)", "", "87", "47 (35.1%)", "", "27.5", "(17.3, 30.2)", "9.5, 54.9", - "0.9 to 91.0", "0.0 to 122.4", "", "0.0334", "1.39", "(1.03, 1.90)", "", - "0.0478", "1.36", "(1.00, 1.86)", "", "83", "70.32", "(62.27, 78.37)", - "-7.71", "(-18.51, 3.10)", "0.1622", "C: Combination", "(N=132)", - "116 (87.9%)", "", "116", "16 (12.1%)", "", "11.1", "(9.6, 15.9)", - "5.3, 25.2", "0.3 to 49.4", "0.1 to 101.6", "", "<0.0001", "2.75", - "(2.05, 3.70)", "", "<0.0001", "2.73", "(2.02, 3.69)", "", "56", "46.39", - "(37.59, 55.18)", "-31.64", "(-43.01, -20.26)", "<0.0001" - ), - .Dim = c(27L, 4L) - ) - - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("TTET01 variant 5: modifying time point", { @@ -393,31 +301,9 @@ testthat::test_that("TTET01 variant 5: modifying time point", { method = "both" ) result <- build_table(l, df = adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Patients with event (%)", "Earliest contributing event", "Death", - "Patients without event (%)", "Time to Event (Months)", "Median", "95% CI", - "25% and 75%-ile", "Range (censored)", "Range (event)", - "Unstratified Analysis", "p-value (log-rank)", "Hazard Ratio", "95% CI", - "6 Months", "Patients remaining at risk", "Event Free Rate (%)", "95% CI", - "Difference in Event Free Rate", "95% CI", "p-value (Z-test)", "A: Drug X", - "(N=134)", "79 (59%)", "", "79", "55 (41%)", "", "41.4", "(27.7, 54.7)", - "15.4, 75.2", "0.4 to 154.7", "0.3 to 116.4", "", "", "", "", "", "106", - "83.83", "(77.49, 90.17)", "", "", "", "B: Placebo", "(N=134)", "87 (64.9%)", - "", "87", "47 (35.1%)", "", "27.5", "(17.3, 30.2)", "9.5, 54.9", - "0.9 to 91.0", "0.0 to 122.4", "", "0.0334", "1.39", "(1.03, 1.90)", "", - "112", "89.16", "(83.80, 94.53)", "5.33", "(-2.97, 13.64)", "0.2080", - "C: Combination", "(N=132)", "116 (87.9%)", "", "116", "16 (12.1%)", "", - "11.1", "(9.6, 15.9)", "5.3, 25.2", "0.3 to 49.4", "0.1 to 101.6", "", - "<0.0001", "2.75", "(2.05, 3.70)", "", "92", "73.40", "(65.72, 81.07)", - "-10.43", "(-20.38, -0.48)", "0.0399" - ), - .Dim = c(23L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("TTET01 variant 6: requesting more than one p-value", { @@ -488,31 +374,7 @@ testthat::test_that("TTET01 variant 6: requesting more than one p-value", { method = "both" ) result <- build_table(l, df = adtte, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Patients with event (%)", "Earliest contributing event", "Death", - "Patients without event (%)", "Time to Event (Months)", "Median", "95% CI", - "25% and 75%-ile", "Range (censored)", "Range (event)", - "Unstratified Analysis", "p-value (log-rank)", "p-value (wald)", - "p-value (likelihood)", "Hazard Ratio", "95% CI", "12 Months", - "Patients remaining at risk", "Event Free Rate (%)", "95% CI", - "Difference in Event Free Rate", "95% CI", "p-value (Z-test)", "A: Drug X", - "(N=134)", "79 (59%)", "", "79", "55 (41%)", "", "41.4", "(27.7, 54.7)", - "15.4, 75.2", "0.4 to 154.7", "0.3 to 116.4", "", "", "", "", "", "", "", - "92", "78.03", "(70.82, 85.24)", "", "", "", "B: Placebo", "(N=134)", - "87 (64.9%)", "", "87", "47 (35.1%)", "", "27.5", "(17.3, 30.2)", - "9.5, 54.9", "0.9 to 91.0", "0.0 to 122.4", "", "0.0334", "0.0342", - "0.0341", "1.39", "(1.03, 1.90)", "", "83", "70.32", "(62.27, 78.37)", - "-7.71", "(-18.51, 3.10)", "0.1622", "C: Combination", "(N=132)", - "116 (87.9%)", "", "116", "16 (12.1%)", "", "11.1", "(9.6, 15.9)", - "5.3, 25.2", "0.3 to 49.4", "0.1 to 101.6", "", "<0.0001", "<0.0001", - "<0.0001", "2.75", "(2.05, 3.70)", "", "56", "46.39", "(37.59, 55.18)", - "-31.64", "(-43.01, -20.26)", "<0.0001" - ), - .Dim = c(25L, 4L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_vst01.R b/tests/testthat/test-table_vst01.R index 93b69c859a..09ac8768ac 100644 --- a/tests/testthat/test-table_vst01.R +++ b/tests/testthat/test-table_vst01.R @@ -62,65 +62,6 @@ testthat::test_that("VST01 default variant is produced correctly", { summarize_colvars(.labels = c(range = "Min - Max")) %>% build_table(df = advs, alt_counts_df = df_adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "", "SCREENING", "n", "Mean (SD)", "Median", - "Min - Max", "BASELINE", "n", "Mean (SD)", "Median", "Min - Max", - "WEEK 1 DAY 8", "n", "Mean (SD)", "Median", "Min - Max", "WEEK 2 DAY 15", - "n", "Mean (SD)", "Median", "Min - Max", "WEEK 3 DAY 22", "n", - "Mean (SD)", "Median", "Min - Max", "WEEK 4 DAY 29", "n", "Mean (SD)", - "Median", "Min - Max", "WEEK 5 DAY 36", "n", "Mean (SD)", "Median", - "Min - Max", "Post-Baseline Last", "n", "Mean (SD)", "Median", - "Min - Max", "Post-Baseline Minimum", "n", "Mean (SD)", "Median", - "Min - Max", "Post-Baseline Maximum", "n", "Mean (SD)", "Median", - "Min - Max", "A: Drug X", "Value at Visit", "(N=134)", "", "134", - "50.0 (7.2)", "49.7", "31.7 - 71.2", "", "134", "48.6 (8.0)", "48.4", - "27.7 - 64.6", "", "134", "50.3 (7.5)", "50.1", "33.0 - 69.0", "", - "134", "50.8 (7.8)", "51.4", "31.9 - 70.3", "", "134", "50.7 (7.8)", - "50.2", "29.1 - 74.9", "", "134", "50.1 (8.1)", "49.3", "29.4 - 71.4", - "", "134", "50.6 (7.5)", "49.4", "35.1 - 72.2", "", "134", "50.6 (7.5)", - "49.4", "35.1 - 72.2", "", "134", "41.6 (4.8)", "42.1", "29.1 - 54.2", - "", "134", "60.0 (4.9)", "59.7", "47.6 - 74.9", "A: Drug X", "Change from Baseline", - "(N=134)", "", "0", "NA", "NA", "NA", "", "134", "0.0 (0.0)", - "0.0", "0.0 - 0.0", "", "134", "1.7 (10.8)", "0.6", "-20.4 - 29.9", - "", "134", "2.2 (11.8)", "3.1", "-23.9 - 39.2", "", "134", "2.1 (10.9)", - "2.6", "-25.8 - 30.7", "", "134", "1.5 (10.9)", "1.2", "-30.9 - 24.8", - "", "134", "2.0 (11.2)", "1.6", "-25.2 - 31.5", "", "134", "2.0 (11.2)", - "1.6", "-25.2 - 31.5", "", "134", "-7.0 (9.6)", "-5.6", "-30.9 - 13.2", - "", "134", "11.4 (9.3)", "11.7", "-8.6 - 39.2", "B: Placebo", - "Value at Visit", "(N=134)", "", "134", "50.8 (8.4)", "50.1", - "29.3 - 69.2", "", "134", "50.4 (7.9)", "50.2", "21.7 - 67.5", - "", "134", "49.7 (7.7)", "49.7", "33.7 - 66.5", "", "134", "49.7 (8.4)", - "50.2", "30.6 - 68.1", "", "134", "49.1 (7.9)", "49.5", "24.5 - 67.1", - "", "134", "49.6 (7.1)", "49.2", "32.7 - 67.0", "", "134", "48.4 (8.0)", - "47.7", "30.4 - 70.6", "", "134", "48.4 (8.0)", "47.7", "30.4 - 70.6", - "", "134", "40.3 (5.3)", "40.3", "24.5 - 55.4", "", "134", "58.5 (4.8)", - "58.3", "47.8 - 70.6", "B: Placebo", "Change from Baseline", - "(N=134)", "", "0", "NA", "NA", "NA", "", "134", "0.0 (0.0)", - "0.0", "0.0 - 0.0", "", "134", "-0.8 (10.9)", "-1.1", "-25.8 - 28.4", - "", "134", "-0.7 (12.4)", "-0.7", "-28.4 - 37.0", "", "134", "-1.3 (11.1)", - "-2.3", "-28.1 - 33.9", "", "134", "-0.8 (10.6)", "-0.8", "-33.2 - 35.9", - "", "134", "-2.1 (11.7)", "-2.9", "-31.2 - 29.2", "", "134", - "-2.1 (11.7)", "-2.9", "-31.2 - 29.2", "", "134", "-10.1 (10.2)", - "-10.7", "-33.2 - 27.7", "", "134", "8.1 (9.5)", "7.5", "-14.0 - 37.0", - "C: Combination", "Value at Visit", "(N=132)", "", "132", "50.2 (7.6)", - "49.6", "26.9 - 70.0", "", "132", "51.1 (7.8)", "50.8", "29.7 - 71.4", - "", "132", "48.9 (7.9)", "47.7", "30.4 - 67.0", "", "132", "50.0 (8.3)", - "51.0", "24.8 - 65.6", "", "132", "49.9 (7.7)", "50.0", "31.5 - 68.5", - "", "132", "49.7 (8.0)", "49.8", "28.7 - 68.4", "", "132", "49.1 (7.6)", - "49.2", "30.6 - 72.9", "", "132", "49.1 (7.6)", "49.2", "30.6 - 72.9", - "", "132", "40.5 (5.3)", "40.5", "24.8 - 54.9", "", "132", "58.6 (4.8)", - "59.0", "41.8 - 72.9", "C: Combination", "Change from Baseline", - "(N=132)", "", "0", "NA", "NA", "NA", "", "132", "0.0 (0.0)", - "0.0", "0.0 - 0.0", "", "132", "-2.3 (10.4)", "-2.2", "-22.1 - 22.4", - "", "132", "-1.1 (11.6)", "-2.3", "-29.2 - 30.7", "", "132", - "-1.2 (10.9)", "-0.6", "-29.7 - 27.0", "", "132", "-1.4 (11.0)", - "-0.2", "-35.5 - 28.4", "", "132", "-2.0 (10.7)", "-2.2", "-30.5 - 34.6", - "", "132", "-2.0 (10.7)", "-2.2", "-30.5 - 34.6", "", "132", "-10.6 (9.1)", - "-10.9", "-35.5 - 13.7", "", "132", "7.5 (9.1)", "6.8", "-17.3 - 34.6" - ), - .Dim = c(53L, 7L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-table_vst02.R b/tests/testthat/test-table_vst02.R index dd10e59bb9..e8e13246ff 100644 --- a/tests/testthat/test-table_vst02.R +++ b/tests/testthat/test-table_vst02.R @@ -1,4 +1,5 @@ # Test the single variant for VST02 + adsl <- adsl_raw advs <- advs_raw @@ -13,33 +14,8 @@ testthat::test_that("1. Vital Sign Abnormalities (Regardless of Abnormality at B count_abnormal("ANRIND", abnormal = list(Low = "LOW", High = "HIGH")) %>% build_table(df = advs_f, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - expected_matrix <- structure( - c( - "", "", "Parameter / Abnormality Direction", "Diastolic Blood Pressure", - "Low", "High", "Pulse Rate", "Low", "High", "Respiratory Rate", - "Low", "High", "Systolic Blood Pressure", "Low", "High", "Temperature", - "Low", "High", "Weight", "Low", "High", "A: Drug X", "(N=134)", - "", "", "53/134 (39.6%)", "53/134 (39.6%)", "", "63/134 (47%)", - "52/134 (38.8%)", "", "59/134 (44%)", "62/134 (46.3%)", "", "54/134 (40.3%)", - "58/134 (43.3%)", "", "59/134 (44%)", "45/134 (33.6%)", "", "62/134 (46.3%)", - "54/134 (40.3%)", "B: Placebo", "(N=134)", "", "", "57/134 (42.5%)", - "51/134 (38.1%)", "", "53/134 (39.6%)", "57/134 (42.5%)", "", - "49/134 (36.6%)", "54/134 (40.3%)", "", "55/134 (41%)", "49/134 (36.6%)", - "", "50/134 (37.3%)", "54/134 (40.3%)", "", "57/134 (42.5%)", - "58/134 (43.3%)", "C: Combination", "(N=132)", "", "", "54/132 (40.9%)", - "52/132 (39.4%)", "", "50/132 (37.9%)", "39/132 (29.5%)", "", - "45/132 (34.1%)", "62/132 (47%)", "", "57/132 (43.2%)", "52/132 (39.4%)", - "", "61/132 (46.2%)", "52/132 (39.4%)", "", "63/132 (47.7%)", - "55/132 (41.7%)", "All Patients", "(N=400)", "", "", "164/400 (41%)", - "156/400 (39%)", "", "166/400 (41.5%)", "148/400 (37%)", "", - "153/400 (38.2%)", "178/400 (44.5%)", "", "166/400 (41.5%)", - "159/400 (39.8%)", "", "170/400 (42.5%)", "151/400 (37.8%)", - "", "182/400 (45.5%)", "167/400 (41.8%)" - ), - .Dim = c(21L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) testthat::test_that("2. Vital Sign Abnormalities (Among Subject Without Abnormality at Baseline, VST02_2)", { @@ -53,32 +29,6 @@ testthat::test_that("2. Vital Sign Abnormalities (Among Subject Without Abnormal count_abnormal("ANRIND", abnormal = list(Low = "LOW", High = "HIGH"), exclude_base_abn = TRUE) %>% build_table(df = advs_f, alt_counts_df = adsl) - result_matrix <- to_string_matrix(result) - - expected_matrix <- structure( - c( - "", "", "Parameter / Abnormality Direction", "Diastolic Blood Pressure", - "Low", "High", "Pulse Rate", "Low", "High", "Respiratory Rate", - "Low", "High", "Systolic Blood Pressure", "Low", "High", "Temperature", - "Low", "High", "Weight", "Low", "High", "A: Drug X", "(N=134)", - "", "", "45/120 (37.5%)", "47/113 (41.6%)", "", "60/125 (48%)", - "47/119 (39.5%)", "", "53/123 (43.1%)", "57/124 (46%)", "", "47/116 (40.5%)", - "55/121 (45.5%)", "", "47/119 (39.5%)", "43/128 (33.6%)", "", - "54/120 (45%)", "49/123 (39.8%)", "B: Placebo", "(N=134)", "", - "", "53/121 (43.8%)", "48/123 (39%)", "", "49/121 (40.5%)", "52/119 (43.7%)", - "", "45/118 (38.1%)", "52/127 (40.9%)", "", "51/120 (42.5%)", - "43/125 (34.4%)", "", "44/119 (37%)", "47/121 (38.8%)", "", "50/117 (42.7%)", - "54/121 (44.6%)", "C: Combination", "(N=132)", "", "", "48/118 (40.7%)", - "48/119 (40.3%)", "", "47/118 (39.8%)", "34/117 (29.1%)", "", - "39/118 (33.1%)", "53/118 (44.9%)", "", "51/120 (42.5%)", "49/124 (39.5%)", - "", "55/115 (47.8%)", "50/122 (41%)", "", "57/119 (47.9%)", "47/113 (41.6%)", - "All Patients", "(N=400)", "", "", "146/359 (40.7%)", "143/355 (40.3%)", - "", "156/364 (42.9%)", "133/355 (37.5%)", "", "137/359 (38.2%)", - "162/369 (43.9%)", "", "149/356 (41.9%)", "147/370 (39.7%)", - "", "146/353 (41.4%)", "140/371 (37.7%)", "", "161/356 (45.2%)", - "150/357 (42%)" - ), - .Dim = c(21L, 5L) - ) - testthat::expect_identical(result_matrix, expected_matrix) + res <- testthat::expect_silent(result) + testthat::expect_snapshot(res) }) diff --git a/tests/testthat/test-test_proportion_diff.R b/tests/testthat/test-test_proportion_diff.R index bb886b67e4..558b68fe61 100644 --- a/tests/testthat/test-test_proportion_diff.R +++ b/tests/testthat/test-test_proportion_diff.R @@ -9,7 +9,7 @@ testthat::test_that("prop_chisq returns right result", { result <- prop_chisq(tbl) expected <- 0.0565 - testthat::expect_equal(result, expected, tolerance = 1e-4, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 1e-3, ignore_attr = FALSE) }) testthat::test_that("prop_cmh returns right result", { @@ -21,7 +21,7 @@ testthat::test_that("prop_cmh returns right result", { result <- prop_cmh(tbl) expected <- 0.6477 - testthat::expect_equal(result, expected, tolerance = 1e-4, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 1e-4, ignore_attr = FALSE) }) testthat::test_that("prop_cmh also works when there are strata with just one observation", { @@ -40,12 +40,12 @@ testthat::test_that("prop_cmh also works when there are strata with just one obs class = "table" ) - result <- testthat::expect_warning( - prop_cmh(tbl), + testthat::expect_warning( + result <- prop_cmh(tbl), "<5 data points in some strata. CMH test may be incorrect." ) expected <- 0.3326 - testthat::expect_equal(result, expected, tol = 1e-4) + testthat::expect_equal(result, expected, tolerance = 1e-4) }) testthat::test_that("prop_fisher returns right result", { @@ -59,7 +59,7 @@ testthat::test_that("prop_fisher returns right result", { result <- prop_fisher(tbl) expected <- 0.1110 - testthat::expect_equal(result, expected, tolerance = 1e-4, check.attributes = FALSE) + testthat::expect_equal(result, expected, tolerance = 1e-3, ignore_attr = FALSE) }) testthat::test_that("prop_schouten returns right result", { @@ -98,7 +98,7 @@ testthat::test_that("prop_schouten returns right result", { 0, 0.9758, 0, 6e-05, 0, 0.10609, 0.01319, 0.44322, 1e-05, 0.00041, 0.05099, 0.00112, 0, 0, 0.56411, 0.00532, 0.00029 ) - testthat::expect_equal(result, expected, tolerance = 1e-5) + testthat::expect_equal(result, expected, tolerance = 1e-4) }) testthat::test_that("s_test_proportion_diff and d_test_proportion_diff return right result", { diff --git a/tests/testthat/test-utils_factor.R b/tests/testthat/test-utils_factor.R index da8d11005b..049b5219aa 100644 --- a/tests/testthat/test-utils_factor.R +++ b/tests/testthat/test-utils_factor.R @@ -18,8 +18,8 @@ testthat::test_that("combine_vectors works correctly", { testthat::test_that("as_factor_keep_attributes works correctly for a character vector", { foo <- formatters::with_label(c("a", "b"), "alphabet") - result <- testthat::expect_warning( - as_factor_keep_attributes(foo, verbose = TRUE), + testthat::expect_warning( + result <- as_factor_keep_attributes(foo, verbose = TRUE), "automatically converting character variable foo to factor" ) expected <- formatters::with_label(factor(c("a", "b")), "alphabet") @@ -28,8 +28,8 @@ testthat::test_that("as_factor_keep_attributes works correctly for a character v testthat::test_that("as_factor_keep_attributes converts empty strings for a character vector", { foo <- formatters::with_label(c("a", "", "b"), "alphabet") - result <- testthat::expect_warning( - as_factor_keep_attributes(foo, na_level = "missing", verbose = TRUE), + testthat::expect_warning( + result <- as_factor_keep_attributes(foo, na_level = "missing", verbose = TRUE), "automatically converting character variable foo to factor" ) expected <- formatters::with_label(factor(c("a", "missing", "b"), levels = c("a", "b", "missing")), "alphabet") @@ -71,7 +71,7 @@ testthat::test_that("bins_percent_labels works as expected", { testthat::test_that("cut_quantile_bins works as expected with default settings", { result <- cut_quantile_bins(cars$speed) - testthat::expect_is(result, "ordered") + testthat::expect_s3_class(result, "ordered") testthat::expect_identical(levels(result), c("[0%,25%]", "(25%,50%]", "(50%,75%]", "(75%,100%]")) testthat::expect_identical(length(result), length(cars$speed)) q1 <- stats::quantile(cars$speed, probs = 0.25) diff --git a/tests/testthat/test-utils_rtables.R b/tests/testthat/test-utils_rtables.R index d15978ab62..40651e0715 100644 --- a/tests/testthat/test-utils_rtables.R +++ b/tests/testthat/test-utils_rtables.R @@ -151,7 +151,7 @@ testthat::test_that("unlist_and_blank_na works as expected if all missing", { testthat::test_that("cfun_by_flag works as expected", { result_fun <- cfun_by_flag(analysis_var = "aval", flag_var = "is_result", format = "xx.xxxx") - testthat::expect_is(result_fun, "function") + testthat::expect_type(result_fun, "closure") df <- data.frame( aval = c(1, 2, 3, 4, 5), arm = c("a", "a", "b", "b", "b"),