From 299b10a66bc6b4364cac2c82e74b0f0a6b4c6282 Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Wed, 13 Nov 2024 03:54:57 +0000 Subject: [PATCH 1/8] adding tests --- tests/testthat.R | 3 + tests/testthat/_snaps/data_snapshot.md | 336 +++++++++++++++++++++++++ tests/testthat/test-data_snapshot.R | 8 + 3 files changed, 347 insertions(+) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/_snaps/data_snapshot.md create mode 100644 tests/testthat/test-data_snapshot.R diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 00000000..c2b87ab3 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,3 @@ +pkg_name <- "autoslider.core" +library(testthat) +test_check(pkg_name, reporter = ParallelProgressReporter$new()) diff --git a/tests/testthat/_snaps/data_snapshot.md b/tests/testthat/_snaps/data_snapshot.md new file mode 100644 index 00000000..7d93fcd2 --- /dev/null +++ b/tests/testthat/_snaps/data_snapshot.md @@ -0,0 +1,336 @@ +# Test data snapshot + + Code + dim(get(datai)) + Output + [1] 1934 93 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 93 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-134 BRA-1 47 YEARS M WHITE NOT H~ BRA Y + 2 AB12345-2 AB12345-~ id-134 BRA-1 47 YEARS M WHITE NOT H~ BRA Y + 3 AB12345-2 AB12345-~ id-134 BRA-1 47 YEARS M WHITE NOT H~ BRA Y + 4 AB12345-2 AB12345-~ id-134 BRA-1 47 YEARS M WHITE NOT H~ BRA Y + 5 AB12345-1 AB12345-~ id-141 BRA-1 35 YEARS F WHITE NOT H~ BRA N + 6 AB12345-1 AB12345-~ id-141 BRA-1 35 YEARS F WHITE NOT H~ BRA N + # i 82 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 13600 88 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 88 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 2 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 3 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 4 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 5 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 6 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + # i 77 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 6400 79 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 79 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 2 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 3 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 4 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 5 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 6 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + # i 68 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 8400 102 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 102 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 2 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 3 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 4 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 5 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 6 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + # i 91 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 3200 65 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 65 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 2 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 3 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 4 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 5 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 6 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + # i 54 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 400 55 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 55 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-1 AB12345-~ id-128 CHN-3 32 YEARS M ASIAN HISPA~ CHN Y + 2 AB12345-2 AB12345-~ id-262 CHN-15 35 YEARS M BLAC~ NOT H~ CHN N + 3 AB12345-1 AB12345-~ id-378 RUS-3 30 YEARS F ASIAN NOT H~ RUS N + 4 AB12345-2 AB12345-~ id-220 CHN-11 26 YEARS F ASIAN NOT H~ CHN N + 5 AB12345-1 AB12345-~ id-267 CHN-7 40 YEARS M ASIAN NOT H~ CHN N + 6 AB12345-2 AB12345-~ id-201 CHN-15 49 YEARS M ASIAN NOT H~ CHN Y + # i 44 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 2800 76 + +--- + + Code + head(get(datai)) + Output + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX + 1 AB12345-2 AB12345-BRA-1-id-105 id-105 BRA-1 38 YEARS M + 2 AB12345-2 AB12345-BRA-1-id-105 id-105 BRA-1 38 YEARS M + 3 AB12345-2 AB12345-BRA-1-id-105 id-105 BRA-1 38 YEARS M + 4 AB12345-2 AB12345-BRA-1-id-105 id-105 BRA-1 38 YEARS M + 5 AB12345-2 AB12345-BRA-1-id-105 id-105 BRA-1 38 YEARS M + 6 AB12345-2 AB12345-BRA-1-id-105 id-105 BRA-1 38 YEARS M + RACE ETHNIC COUNTRY DTHFL INVID + 1 BLACK OR AFRICAN AMERICAN HISPANIC OR LATINO BRA N INV ID BRA-1 + 2 BLACK OR AFRICAN AMERICAN HISPANIC OR LATINO BRA N INV ID BRA-1 + 3 BLACK OR AFRICAN AMERICAN HISPANIC OR LATINO BRA N INV ID BRA-1 + 4 BLACK OR AFRICAN AMERICAN HISPANIC OR LATINO BRA N INV ID BRA-1 + 5 BLACK OR AFRICAN AMERICAN HISPANIC OR LATINO BRA N INV ID BRA-1 + 6 BLACK OR AFRICAN AMERICAN HISPANIC OR LATINO BRA N INV ID BRA-1 + INVNAM ARM ARMCD ACTARM ACTARMCD TRT01P TRT01A + 1 Dr. BRA-1 Doe A: Drug X ARM A A: Drug X ARM A A: Drug X A: Drug X + 2 Dr. BRA-1 Doe A: Drug X ARM A A: Drug X ARM A A: Drug X A: Drug X + 3 Dr. BRA-1 Doe A: Drug X ARM A A: Drug X ARM A A: Drug X A: Drug X + 4 Dr. BRA-1 Doe A: Drug X ARM A A: Drug X ARM A A: Drug X A: Drug X + 5 Dr. BRA-1 Doe A: Drug X ARM A A: Drug X ARM A A: Drug X A: Drug X + 6 Dr. BRA-1 Doe A: Drug X ARM A A: Drug X ARM A A: Drug X A: Drug X + TRT02P TRT02A REGION1 STRATA1 STRATA2 BMRKR1 BMRKR2 ITTFL + 1 C: Combination A: Drug X South America B S1 4.156914 MEDIUM Y + 2 C: Combination A: Drug X South America B S1 4.156914 MEDIUM Y + 3 C: Combination A: Drug X South America B S1 4.156914 MEDIUM Y + 4 C: Combination A: Drug X South America B S1 4.156914 MEDIUM Y + 5 C: Combination A: Drug X South America B S1 4.156914 MEDIUM Y + 6 C: Combination A: Drug X South America B S1 4.156914 MEDIUM Y + SAFFL BMEASIFL BEP01FL AEWITHFL RANDDT TRTSDTM + 1 Y Y Y N 2020-03-08 2020-03-08 05:39:28 + 2 Y Y Y N 2020-03-08 2020-03-08 05:39:28 + 3 Y Y Y N 2020-03-08 2020-03-08 05:39:28 + 4 Y Y Y N 2020-03-08 2020-03-08 05:39:28 + 5 Y Y Y N 2020-03-08 2020-03-08 05:39:28 + 6 Y Y Y N 2020-03-08 2020-03-08 05:39:28 + TRTEDTM TRT01SDTM TRT01EDTM + 1 2022-02-14 20:58:26 2020-03-08 05:39:28 2021-02-14 14:58:26 + 2 2022-02-14 20:58:26 2020-03-08 05:39:28 2021-02-14 14:58:26 + 3 2022-02-14 20:58:26 2020-03-08 05:39:28 2021-02-14 14:58:26 + 4 2022-02-14 20:58:26 2020-03-08 05:39:28 2021-02-14 14:58:26 + 5 2022-02-14 20:58:26 2020-03-08 05:39:28 2021-02-14 14:58:26 + 6 2022-02-14 20:58:26 2020-03-08 05:39:28 2021-02-14 14:58:26 + TRT02SDTM TRT02EDTM AP01SDTM + 1 2021-02-14 14:58:26 2022-02-14 20:58:26 2020-03-08 05:39:28 + 2 2021-02-14 14:58:26 2022-02-14 20:58:26 2020-03-08 05:39:28 + 3 2021-02-14 14:58:26 2022-02-14 20:58:26 2020-03-08 05:39:28 + 4 2021-02-14 14:58:26 2022-02-14 20:58:26 2020-03-08 05:39:28 + 5 2021-02-14 14:58:26 2022-02-14 20:58:26 2020-03-08 05:39:28 + 6 2021-02-14 14:58:26 2022-02-14 20:58:26 2020-03-08 05:39:28 + AP01EDTM AP02SDTM AP02EDTM EOSSTT + 1 2021-02-14 14:58:26 2021-02-14 14:58:26 2022-02-14 20:58:26 DISCONTINUED + 2 2021-02-14 14:58:26 2021-02-14 14:58:26 2022-02-14 20:58:26 DISCONTINUED + 3 2021-02-14 14:58:26 2021-02-14 14:58:26 2022-02-14 20:58:26 DISCONTINUED + 4 2021-02-14 14:58:26 2021-02-14 14:58:26 2022-02-14 20:58:26 DISCONTINUED + 5 2021-02-14 14:58:26 2021-02-14 14:58:26 2022-02-14 20:58:26 DISCONTINUED + 6 2021-02-14 14:58:26 2021-02-14 14:58:26 2022-02-14 20:58:26 DISCONTINUED + EOTSTT EOSDT EOSDY DCSREAS DTHDT DTHCAUS DTHCAT + 1 DISCONTINUED 2022-02-14 709 PROTOCOL VIOLATION + 2 DISCONTINUED 2022-02-14 709 PROTOCOL VIOLATION + 3 DISCONTINUED 2022-02-14 709 PROTOCOL VIOLATION + 4 DISCONTINUED 2022-02-14 709 PROTOCOL VIOLATION + 5 DISCONTINUED 2022-02-14 709 PROTOCOL VIOLATION + 6 DISCONTINUED 2022-02-14 709 PROTOCOL VIOLATION + LDDTHELD LDDTHGR1 LSTALVDT DTHADY ADTHAUT AGEGR1 TRTDURD DCSREAS_GRP + 1 NA 2022-03-09 NA <65 707.6382 Non-Safety + 2 NA 2022-03-09 NA <65 707.6382 Non-Safety + 3 NA 2022-03-09 NA <65 707.6382 Non-Safety + 4 NA 2022-03-09 NA <65 707.6382 Non-Safety + 5 NA 2022-03-09 NA <65 707.6382 Non-Safety + 6 NA 2022-03-09 NA <65 707.6382 Non-Safety + PARAM PARAMCD AVISIT AVISITN + 1 Sum of Longest Diameter by Investigator SLDINV POST-BASELINE MINIMUM 999 + 2 Sum of Longest Diameter by Investigator SLDINV END OF INDUCTION 999 + 3 Sum of Longest Diameter by Investigator SLDINV BASELINE 0 + 4 Sum of Longest Diameter by Investigator SLDINV CYCLE 4 DAY 1 4 + 5 Sum of Longest Diameter by Investigator SLDINV SCREENING -1 + 6 Sum of Longest Diameter by Investigator SLDINV FOLLOW UP 999 + ADTM ADY DTYPE AVAL AVALC AVALU BASE ABLFL + 1 2021-06-19 468 MINIMUM 141.6140 141.614020702645 mm 167.4415 + 2 2021-06-19 468 141.6140 141.614020702645 mm 167.4415 + 3 2020-03-08 0 NA mm 167.4415 Y + 4 2021-07-27 506 195.2095 195.209453323539 mm 167.4415 + 5 2019-11-29 -100 171.4226 171.422566332973 mm 167.4415 + 6 2022-01-06 669 210.8322 210.832161998961 mm 167.4415 + CHG PCHG ONTRTFL ANL01FL ANL02FL ANL03FL + 1 -25.82752 -15.42480 Y Y + 2 -25.82752 -15.42480 Y Y + 3 NA NA Y Y + 4 27.76791 16.58365 Y Y + 5 NA NA + 6 43.39062 25.91389 Y Y + +--- + + Code + dim(get(datai)) + Output + [1] 2000 67 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 67 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 2 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 3 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 4 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 5 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 6 AB12345-2 AB12345-~ id-134 BRA-1 47 YEARS M WHITE NOT H~ BRA Y + # i 56 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + +--- + + Code + dim(get(datai)) + Output + [1] 16800 87 + +--- + + Code + head(get(datai)) + Output + # A tibble: 6 x 87 + STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL + + 1 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 2 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 3 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 4 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 5 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + 6 AB12345-2 AB12345-~ id-105 BRA-1 38 YEARS M BLAC~ HISPA~ BRA N + # i 76 more variables: INVID , INVNAM , ARM , ARMCD , + # ACTARM , ACTARMCD , TRT01P , TRT01A , TRT02P , + # TRT02A , REGION1 , STRATA1 , STRATA2 , BMRKR1 , + # BMRKR2 , ITTFL , SAFFL , BMEASIFL , BEP01FL , + # AEWITHFL , RANDDT , TRTSDTM , TRTEDTM , + # TRT01SDTM , TRT01EDTM , TRT02SDTM , TRT02EDTM , + # AP01SDTM , AP01EDTM , AP02SDTM , AP02EDTM , ... + diff --git a/tests/testthat/test-data_snapshot.R b/tests/testthat/test-data_snapshot.R new file mode 100644 index 00000000..ed1d2dc6 --- /dev/null +++ b/tests/testthat/test-data_snapshot.R @@ -0,0 +1,8 @@ +test_that("Test data snapshot", { + eg_dataname <- data(package = "autoslider.core")$results[, "Item"] %>% .[grep("eg_", .)] + for (datai in eg_dataname) { + expect_snapshot(dim(get(datai))) + expect_snapshot(head(get(datai))) + } +}) + From 952913b9d9463d2f917cf153bcbf1d141ae0c490 Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Wed, 13 Nov 2024 07:22:14 +0000 Subject: [PATCH 2/8] adding tests --- tests/testthat/test-data_snapshot.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-data_snapshot.R b/tests/testthat/test-data_snapshot.R index ed1d2dc6..94375737 100644 --- a/tests/testthat/test-data_snapshot.R +++ b/tests/testthat/test-data_snapshot.R @@ -5,4 +5,3 @@ test_that("Test data snapshot", { expect_snapshot(head(get(datai))) } }) - From 62019593f93ce4e2a2290d0ac84e94569bb416d6 Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Wed, 13 Nov 2024 16:58:23 +0800 Subject: [PATCH 3/8] update --- inst/WORDLIST | 0 tests/testthat.R | 0 tests/testthat/_snaps/data_snapshot.md | 0 tests/testthat/test-data_snapshot.R | 0 tests/testthat/test-decorate.R | 46 ++++++++++++++++++++++++++ tests/testthat/test-log.R | 4 +++ tests/testthat/test-save-output.R | 10 ++++++ tests/testthat/test-save_output.R | 32 ++++++++++++++++++ tests/testthat/test-t_dd_slide.R | 22 ++++++++++++ tests/testthat/test-t_dm_slide.R | 17 ++++++++++ tests/testthat/test-t_dor_slide.R | 20 +++++++++++ 11 files changed, 151 insertions(+) mode change 100644 => 100755 inst/WORDLIST mode change 100644 => 100755 tests/testthat.R mode change 100644 => 100755 tests/testthat/_snaps/data_snapshot.md mode change 100644 => 100755 tests/testthat/test-data_snapshot.R create mode 100755 tests/testthat/test-decorate.R create mode 100755 tests/testthat/test-log.R create mode 100755 tests/testthat/test-save-output.R create mode 100755 tests/testthat/test-save_output.R create mode 100755 tests/testthat/test-t_dd_slide.R create mode 100755 tests/testthat/test-t_dm_slide.R create mode 100644 tests/testthat/test-t_dor_slide.R diff --git a/inst/WORDLIST b/inst/WORDLIST old mode 100644 new mode 100755 diff --git a/tests/testthat.R b/tests/testthat.R old mode 100644 new mode 100755 diff --git a/tests/testthat/_snaps/data_snapshot.md b/tests/testthat/_snaps/data_snapshot.md old mode 100644 new mode 100755 diff --git a/tests/testthat/test-data_snapshot.R b/tests/testthat/test-data_snapshot.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-decorate.R b/tests/testthat/test-decorate.R new file mode 100755 index 00000000..44287c36 --- /dev/null +++ b/tests/testthat/test-decorate.R @@ -0,0 +1,46 @@ +set.seed(1) + +sample_df <- data.frame( + group = factor(rep(letters[1:3], each = 10)), + value = rnorm(30) +) + +group_means_df <- setNames( + aggregate(value ~ group, sample_df, mean), + c("group", "group_mean") +) +a <- ggplot(data = sample_df, mapping = aes(x = group, y = value)) + + geom_point() + + geom_point( + mapping = aes(y = group_mean), data = group_means_df, + colour = "red", size = 3 + ) +aa <- list(a, a) + + +test_that("Test decoreate not to throw", { + # test for decorate.autoslider_error + e <- autoslideR:::autoslider_error("error", list(program = "", suffix = ""), step = "test") + expect_no_error(decorate.autoslider_error(e)) + + # test for decorate.list + expect_no_error(decorate.list(aa, + titles = "some generic title", + footnotes = "some generic footnotes" + )) +}) + + +test_that("Test print not to throw", { + # print.decoratedGrob + expect_no_error(print(aa[[2]])) + + # print.decoratedGrobSet + expect_no_error(print(aa[2])) + expect_no_error(print(aa)) +}) + + +test_that("Test decoreate throw", { + expect_error(decorate.default(e), "default decorate function does not exist", ignore.case = TRUE) +}) diff --git a/tests/testthat/test-log.R b/tests/testthat/test-log.R new file mode 100755 index 00000000..c2942a44 --- /dev/null +++ b/tests/testthat/test-log.R @@ -0,0 +1,4 @@ +test_that("Test some functions in log.R", { + testthat::expect_no_error(log_success_infomation(100, 0)) + testthat::expect_no_error(log_success_infomation(99, 1)) +}) diff --git a/tests/testthat/test-save-output.R b/tests/testthat/test-save-output.R new file mode 100755 index 00000000..85752e3d --- /dev/null +++ b/tests/testthat/test-save-output.R @@ -0,0 +1,10 @@ +test_that("save an output", { + output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") + testthat::expect_no_error( + save_output( + output, + file_name = "t_ds_output", + save_rds = TRUE + ) + ) +}) diff --git a/tests/testthat/test-save_output.R b/tests/testthat/test-save_output.R new file mode 100755 index 00000000..74c52c19 --- /dev/null +++ b/tests/testthat/test-save_output.R @@ -0,0 +1,32 @@ +test_that("Test save_output (Save an Output)", { + library(dplyr) + adsl <- eg_adsl %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) + adae <- eg_adae %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) + adae$ATOXGR <- adae$AETOXGR + output_dir <- tempdir() + + expect_snapshot(print(t_ae_pt_slide(adsl, adae, "TRT01A", 2) %>% + decorate( + title = "Serious Adverse Events, Safety-Evaluable Patients", + footnote = "", + paper = "P8", + for_test = TRUE + ) %>% + save_output( + file_name = file.path(output_dir, "t_ae_SER_SE"), + save_rds = TRUE + ))) +}) + +test_that("save an output", { + output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") + testthat::expect_no_error( + save_output( + output, + file_name = "t_ds_output", + save_rds = TRUE + ) + ) +}) diff --git a/tests/testthat/test-t_dd_slide.R b/tests/testthat/test-t_dd_slide.R new file mode 100755 index 00000000..6e7a211b --- /dev/null +++ b/tests/testthat/test-t_dd_slide.R @@ -0,0 +1,22 @@ +test_that("Test table creation of t_dd_slide (death table)", { + expect_snapshot(t_dd_slide(testdata$adsl, "TRT01A")) +}) + +test_that("Test t_dd_slide table with expected Error", { + expect_snapshot(error = TRUE, t_dd_slide(adsl, "TRT")) +}) + +test_that("Test table creation of with null_report", { + expect_snapshot(t_dd_slide(testdata$adsl[0, ], "TRT01A")) +}) + + +test_that("Test table creation of t_dd_slide (death table)", { + expect_snapshot(t_dd_slide(testdata$adsl, "TRT01A", split_by_study = TRUE)) +}) + + +test_that("Test table creation of t_dd_slide (death table)", { + expect_snapshot(t_dd_slide(testdata$adsl, "TRT01A", split_by_study = TRUE, side_by_side = TRUE)) + expect_warning(t_dd_slide(testdata$adsl, "TRT01A", split_by_study = TRUE, side_by_side = TRUE)) +}) diff --git a/tests/testthat/test-t_dm_slide.R b/tests/testthat/test-t_dm_slide.R new file mode 100755 index 00000000..17824c41 --- /dev/null +++ b/tests/testthat/test-t_dm_slide.R @@ -0,0 +1,17 @@ +test_that("Test demographic table creation of t_dm_slide", { + adsl <- eg_adsl + expect_snapshot(t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"))) + + expect_snapshot(t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), side_by_side = 2)) + + expect_snapshot(t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), + split_by_study = TRUE, side_by_side = 2 + )) + + expect_warning(t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), + split_by_study = TRUE, side_by_side = 2 + )) + expect_snapshot(t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), + split_by_study = TRUE, side_by_side = 2 + )) +}) diff --git a/tests/testthat/test-t_dor_slide.R b/tests/testthat/test-t_dor_slide.R new file mode 100644 index 00000000..3d9b26a0 --- /dev/null +++ b/tests/testthat/test-t_dor_slide.R @@ -0,0 +1,20 @@ +test_that("Test DOR table when time unit is 'DAYS'", { + adsl <- eg_adsl %>% + dplyr::mutate(TRT01P = factor(TRT01P, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + adtte <- eg_adtte %>% + dplyr::filter(PARAMCD == "OS") %>% + dplyr::mutate(TRT01P = factor(TRT01P, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + + expect_snapshot(t_dor_slide(adsl, adtte)) +}) + +test_that("Test DOR table when time unit is 'YEARS'", { + adsl <- eg_adsl %>% + dplyr::mutate(TRT01P = factor(TRT01P, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + adtte <- eg_adtte %>% + dplyr::filter(PARAMCD == "OS") %>% + dplyr::mutate(TRT01P = factor(TRT01P, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + levels(adtte$AVALU)[2] <- "YEARS" + + expect_snapshot(t_dor_slide(adsl, adtte)) +}) From f74b30dad546ea7ee6c5948b2b9d2cff4cb9f1cd Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Wed, 13 Nov 2024 12:59:13 +0000 Subject: [PATCH 4/8] addin tests --- tests/testthat/_snaps/t_dd_slide.md | 8 ++ tests/testthat/_snaps/t_dm_slide.md | 177 +++++++++++++++++++++++++++ tests/testthat/_snaps/t_dor_slide.md | 30 +++++ tests/testthat/setup-options.R | 11 ++ tests/testthat/setup.R | 147 ++++++++++++++++++++++ tests/testthat/test-data_snapshot.R | 2 +- tests/testthat/test-save-output.R | 10 -- tests/testthat/test-save_output.R | 12 ++ 8 files changed, 386 insertions(+), 11 deletions(-) create mode 100644 tests/testthat/_snaps/t_dd_slide.md create mode 100644 tests/testthat/_snaps/t_dm_slide.md create mode 100644 tests/testthat/_snaps/t_dor_slide.md create mode 100644 tests/testthat/setup-options.R create mode 100644 tests/testthat/setup.R delete mode 100755 tests/testthat/test-save-output.R diff --git a/tests/testthat/_snaps/t_dd_slide.md b/tests/testthat/_snaps/t_dd_slide.md new file mode 100644 index 00000000..fd9589de --- /dev/null +++ b/tests/testthat/_snaps/t_dd_slide.md @@ -0,0 +1,8 @@ +# Test t_dd_slide table with expected Error + + Code + t_dd_slide(adsl, "TRT") + Condition + Error: + ! object 'adsl' not found + diff --git a/tests/testthat/_snaps/t_dm_slide.md b/tests/testthat/_snaps/t_dm_slide.md new file mode 100644 index 00000000..5e48f9b3 --- /dev/null +++ b/tests/testthat/_snaps/t_dm_slide.md @@ -0,0 +1,177 @@ +# Test demographic table creation of t_dm_slide + + Code + t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY")) + Output + Demographic slide + + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X B: Placebo C: Combination All Patients All Patients + —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Sex + F 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) 231 (57.8%) + M 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) 169 (42.2%) + Age + Median 33.00 35.00 35.00 34.00 34.00 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 20.0 - 69.0 + Race + ASIAN 68 (50.7%) 67 (50%) 73 (55.3%) 208 (52%) 208 (52%) + BLACK OR AFRICAN AMERICAN 31 (23.1%) 28 (20.9%) 32 (24.2%) 91 (22.8%) 91 (22.8%) + WHITE 27 (20.1%) 26 (19.4%) 21 (15.9%) 74 (18.5%) 74 (18.5%) + AMERICAN INDIAN OR ALASKA NATIVE 8 (6%) 11 (8.2%) 6 (4.5%) 25 (6.2%) 25 (6.2%) + MULTIPLE 0 1 (0.7%) 0 1 (0.2%) 1 (0.2%) + NATIVE HAWAIIAN OR OTHER PACIFIC ISLANDER 0 1 (0.7%) 0 1 (0.2%) 1 (0.2%) + OTHER 0 0 0 0 0 + UNKNOWN 0 0 0 0 0 + Ethnicity + NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) 27 (6.8%) 27 (6.8%) + HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) 48 (12%) 48 (12%) + NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) 308 (77%) 308 (77%) + UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) 17 (4.2%) 17 (4.2%) + Country + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) 219 (54.8%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10%) 40 (10%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) 30 (7.5%) + PAK 12 (9%) 9 (6.7%) 10 (7.6%) 31 (7.8%) 31 (7.8%) + NGA 8 (6%) 7 (5.2%) 11 (8.3%) 26 (6.5%) 26 (6.5%) + RUS 5 (3.7%) 8 (6%) 6 (4.5%) 19 (4.8%) 19 (4.8%) + JPN 5 (3.7%) 4 (3%) 9 (6.8%) 18 (4.5%) 18 (4.5%) + GBR 4 (3%) 3 (2.2%) 2 (1.5%) 9 (2.2%) 9 (2.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2%) 8 (2%) + CHE 0 0 0 0 0 + +--- + + Code + t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), + side_by_side = 2) + Output + Demographic slide + + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X B: Placebo C: Combination All Patients + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Sex + F 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) + M 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) + Age + Median 33.00 35.00 35.00 34.00 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 + Race + 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 + Ethnicity + NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) 27 (6.8%) + HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) 48 (12%) + NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) 308 (77%) + UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) 17 (4.2%) + Country + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + PAK 12 (9%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + NGA 8 (6%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + RUS 5 (3.7%) 8 (6%) 6 (4.5%) 19 (4.8%) + JPN 5 (3.7%) 4 (3%) 9 (6.8%) 18 (4.5%) + GBR 4 (3%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2%) + CHE 0 0 0 0 + +--- + + Code + t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), + split_by_study = TRUE, side_by_side = 2) + Condition + Warning in `build_table_header()`: + split_by_study argument will be ignored + Output + Demographic slide + + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X B: Placebo C: Combination All Patients + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Sex + F 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) + M 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) + Age + Median 33.00 35.00 35.00 34.00 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 + Race + 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 + Ethnicity + NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) 27 (6.8%) + HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) 48 (12%) + NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) 308 (77%) + UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) 17 (4.2%) + Country + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + PAK 12 (9%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + NGA 8 (6%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + RUS 5 (3.7%) 8 (6%) 6 (4.5%) 19 (4.8%) + JPN 5 (3.7%) 4 (3%) 9 (6.8%) 18 (4.5%) + GBR 4 (3%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2%) + CHE 0 0 0 0 + +--- + + Code + t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), + split_by_study = TRUE, side_by_side = 2) + Condition + Warning in `build_table_header()`: + split_by_study argument will be ignored + Output + Demographic slide + + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + A: Drug X B: Placebo C: Combination All Patients + ——————————————————————————————————————————————————————————————————————————————————————————————————————— + Sex + F 79 (59%) 82 (61.2%) 70 (53%) 231 (57.8%) + M 55 (41%) 52 (38.8%) 62 (47%) 169 (42.2%) + Age + Median 33.00 35.00 35.00 34.00 + Min - Max 21.0 - 50.0 21.0 - 62.0 20.0 - 69.0 20.0 - 69.0 + Race + 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 + Ethnicity + NOT REPORTED 6 (4.5%) 10 (7.5%) 11 (8.3%) 27 (6.8%) + HISPANIC OR LATINO 15 (11.2%) 18 (13.4%) 15 (11.4%) 48 (12%) + NOT HISPANIC OR LATINO 104 (77.6%) 103 (76.9%) 101 (76.5%) 308 (77%) + UNKNOWN 9 (6.7%) 3 (2.2%) 5 (3.8%) 17 (4.2%) + Country + CHN 74 (55.2%) 81 (60.4%) 64 (48.5%) 219 (54.8%) + USA 10 (7.5%) 13 (9.7%) 17 (12.9%) 40 (10%) + BRA 13 (9.7%) 7 (5.2%) 10 (7.6%) 30 (7.5%) + PAK 12 (9%) 9 (6.7%) 10 (7.6%) 31 (7.8%) + NGA 8 (6%) 7 (5.2%) 11 (8.3%) 26 (6.5%) + RUS 5 (3.7%) 8 (6%) 6 (4.5%) 19 (4.8%) + JPN 5 (3.7%) 4 (3%) 9 (6.8%) 18 (4.5%) + GBR 4 (3%) 3 (2.2%) 2 (1.5%) 9 (2.2%) + CAN 3 (2.2%) 2 (1.5%) 3 (2.3%) 8 (2%) + CHE 0 0 0 0 + diff --git a/tests/testthat/_snaps/t_dor_slide.md b/tests/testthat/_snaps/t_dor_slide.md new file mode 100644 index 00000000..3139aa15 --- /dev/null +++ b/tests/testthat/_snaps/t_dor_slide.md @@ -0,0 +1,30 @@ +# Test DOR table when time unit is 'DAYS' + + Code + t_dor_slide(adsl, adtte) + Output + DOR slide + + —————————————————————————————————————————————————————————————————————————— + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + —————————————————————————————————————————————————————————————————————————— + Responders 134 134 132 + With subsequent event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) + Median (Months, 95% CI) NA (9.3, NA) NA (9.4, NA) 9.4 (7.6, NA) + +# Test DOR table when time unit is 'YEARS' + + Code + t_dor_slide(adsl, adtte) + Output + DOR slide + + ————————————————————————————————————————————————————————————————————————————————————— + A: Drug X B: Placebo C: Combination + (N=134) (N=134) (N=132) + ————————————————————————————————————————————————————————————————————————————————————— + Responders 134 134 132 + With subsequent event (%) 58 (43.3%) 58 (43.3%) 69 (52.3%) + Median (Months, 95% CI) NA (3397.7, NA) NA (3447.1, NA) 3439.6 (2784.8, NA) + diff --git a/tests/testthat/setup-options.R b/tests/testthat/setup-options.R new file mode 100644 index 00000000..a1244da3 --- /dev/null +++ b/tests/testthat/setup-options.R @@ -0,0 +1,11 @@ +opts_partial_match_old <- list( + warnPartialMatchDollar = getOption("warnPartialMatchDollar"), + warnPartialMatchArgs = getOption("warnPartialMatchArgs"), + warnPartialMatchAttr = getOption("warnPartialMatchAttr") +) + +opts_partial_match_new <- list( + warnPartialMatchDollar = TRUE, + warnPartialMatchArgs = TRUE, + warnPartialMatchAttr = TRUE +) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 00000000..49a917f4 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1,147 @@ +# Extra libraries (suggested) for tests +library(dplyr) +library(assertthat) +library(rtables) +library(tern) +library(purrr) +require("ggplot2") +set.seed(12893) +# skip_if_too_deep +skip_if_too_deep <- function(depth) { # nolintr + checkmate::assert_number(depth, lower = 0, upper = 5) + + testing_depth <- getOption("TESTING_DEPTH") + if (is.null(testing_depth)) testing_depth <- Sys.getenv("TESTING_DEPTH") + + testing_depth <- tryCatch( + as.numeric(testing_depth), + error = function(error) 3, + warning = function(warning) 3 + ) + + if (length(testing_depth) != 1 || is.na(testing_depth)) testing_depth <- 3 + + if (testing_depth < depth) { + testthat::skip(paste("testing depth", testing_depth, "is below current testing specification", depth)) + } +} + + +expect_snapshot_ggplot <- function(title, fig, width = NA, height = NA) { + testthat::skip_on_ci() + testthat::skip_if_not_installed("svglite") + + name <- paste0(title, ".svg") + path <- tempdir() + withr::with_options( + opts_partial_match_old, + suppressMessages(ggplot2::ggsave(name, fig, path = path, width = width, height = height)) + ) + path <- file.path(path, name) + + testthat::announce_snapshot_file(name = name) + testthat::expect_snapshot_file(path, name) +} + +adsl <- eg_adsl %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) %>% + preprocess_t_dd() %>% + mutate(DISTRTFL = sample(c("Y", "N"), size = length(TRT01A), replace = TRUE, prob = c(.1, .9))) %>% + # preprocess_t_ds() %>% + mutate( + DTRFL = if_else(EOTSTT == "DISCONTINUED", "Y", "N"), + TRTSDT = as.Date(TRTSDTM) + ) +adsl$FASFL <- adsl$SAFFL +adsl_two_arm <- adsl %>% + dplyr::filter(TRT01A %in% c("A: Drug X", "B: Placebo")) %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) + +adae <- eg_adae %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) +adae <- adae %>% mutate( + dis_flags = ifelse(AEACN == "DRUG WITHDRAWN", TRUE, FALSE), + red_flags = ifelse(AEACN == "DRUG REDUCED", TRUE, FALSE), + int_flags = ifelse(AEACN == "DRUG INTERRUPTED", TRUE, FALSE), + dis_flags = ifelse(AEACN == "DRUG WITHDRAWN", TRUE, FALSE), + red_flags = ifelse(AEACN == "DRUG REDUCED", TRUE, FALSE), + int_flags = ifelse(AEACN == "DRUG INTERRUPTED", TRUE, FALSE), + ATOXGR = AETOXGR +) + +# ADAE for AESEV grading +adae_aesev <- adae %>% + mutate(AESEV = as.factor(case_when( + AETOXGR %in% c("1", "2") ~ "MILD", + AETOXGR == "3" ~ "MODERATE", + AETOXGR %in% c("4", "5") ~ "SEVERE" + ))) + +# ADAE with custom grouping +adae_custom <- adae %>% + mutate(AEGRP = as.factor(case_when( + AETOXGR %in% c("1", "2") ~ "Grade 1-2", + AETOXGR %in% c("3", "4", "5") ~ "Grade 3-5" + ))) + +# ADAE for ATOXGR grading +adae_atoxgr <- adae %>% + mutate(ATOXGR = AETOXGR) + +adae_two_arm <- adae %>% + dplyr::filter(TRT01A %in% c("A: Drug X", "B: Placebo")) %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) + +advs <- eg_advs %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + +adrs <- eg_adrs %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) %>% + dplyr::filter(PARAMCD == "INVET") + +adtte <- eg_adtte %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + +adlb <- eg_adlb %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + +adeg <- eg_adeg %>% + mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo", "C: Combination"))) + +adex <- eg_adex +adex_tdosint <- adex %>% + filter(PARAM == "Total dose administered") %>% + mutate( + AVAL = ASEQ / max(ASEQ) * 100, + PARAMCD = "TDOSINT", + PARAM = "Fake dose intensity" + ) +adex_tdurd <- adex %>% + filter(PARAM == "Total dose administered") %>% + mutate( + AVAL = ASEQ, + PARAMCD = "TDURD", + PARAM = "Fake treatment duration" + ) +adex <- data.frame(Reduce("rbind", list(adex, adex_tdosint, adex_tdurd))) + +testdata <- list( + "adsl" = adsl, + "adae" = adae, + "adae_aesev" = adae_aesev, + "adae_atoxgr" = adae_atoxgr, + "adae_custom" = adae_custom, + "adtte" = adtte, + "adrs" = adrs, + "advs" = advs, + "adlb" = adlb, + "adeg" = adeg, + "adex" = adex +) + +testdata_two_arm <- list( + "adsl" = adsl_two_arm, + "adae" = adae_two_arm +) + + diff --git a/tests/testthat/test-data_snapshot.R b/tests/testthat/test-data_snapshot.R index 94375737..190d8308 100755 --- a/tests/testthat/test-data_snapshot.R +++ b/tests/testthat/test-data_snapshot.R @@ -1,5 +1,5 @@ test_that("Test data snapshot", { - eg_dataname <- data(package = "autoslider.core")$results[, "Item"] %>% .[grep("eg_", .)] + eg_dataname <- data(package = "autoslider.core")$results[, "Item"] %>% .[grep("eg_", .)] %>% sort for (datai in eg_dataname) { expect_snapshot(dim(get(datai))) expect_snapshot(head(get(datai))) diff --git a/tests/testthat/test-save-output.R b/tests/testthat/test-save-output.R deleted file mode 100755 index 85752e3d..00000000 --- a/tests/testthat/test-save-output.R +++ /dev/null @@ -1,10 +0,0 @@ -test_that("save an output", { - output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") - testthat::expect_no_error( - save_output( - output, - file_name = "t_ds_output", - save_rds = TRUE - ) - ) -}) diff --git a/tests/testthat/test-save_output.R b/tests/testthat/test-save_output.R index 74c52c19..300e3a74 100755 --- a/tests/testthat/test-save_output.R +++ b/tests/testthat/test-save_output.R @@ -1,3 +1,15 @@ +test_that("save an output", { + output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") + testthat::expect_no_error( + save_output( + output, + file_name = "t_ds_output", + save_rds = TRUE + ) + ) +}) + + test_that("Test save_output (Save an Output)", { library(dplyr) adsl <- eg_adsl %>% From c04aff0e3ed61928f973c32dc15a07abd705c790 Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Wed, 13 Nov 2024 13:14:32 +0000 Subject: [PATCH 5/8] update snap --- NAMESPACE | 1 + R/null_report.R | 41 ++++++++++++++++++ man/null_report.Rd | 45 ++++++++++++++++++++ tests/testthat/_snaps/t_dd_slide.md | 65 ++++++++++++++++++++++++++++- tests/testthat/test-decorate.R | 2 +- 5 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 R/null_report.R create mode 100644 man/null_report.Rd diff --git a/NAMESPACE b/NAMESPACE index b7b2d652..9e2f76ed 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,6 +32,7 @@ export(lyt_to_side_by_side) export(lyt_to_side_by_side_two_data) export(mutate_actarm) export(na_replace) +export(null_report) export(orange_format) export(perc_perc) export(ph_with_img) diff --git a/R/null_report.R b/R/null_report.R new file mode 100644 index 00000000..f9ffe271 --- /dev/null +++ b/R/null_report.R @@ -0,0 +1,41 @@ +#' Null report +#' +#' @author Thomas Neitmann (`neitmant`) +#' @export +#' +#' @details +#' This will create a null report similar as STREAM does. You can use +#' it inside output functions as shown in the example below. +#' +#' @examples +#' library(dplyr) +#' library(filters) +#' data <- list( +#' adsl = eg_adsl, +#' adae = eg_adae %>% mutate(AREL = "") +#' ) +#' +#' null_report() +#' +#' ## An example how to use the `null_report()` inside an output function +#' t_ae <- function(datasets) { +#' trt <- "ACTARM" +#' anl <- semi_join( +#' datasets$adae, +#' datasets$adsl, +#' by = c("STUDYID", "USUBJID") +#' ) +#' +#' return(null_report()) +#' } +#' +#' data %>% +#' apply_filter("SER_SE") %>% +#' t_ae() +#' +null_report <- function() { + rtable( + header = " ", + rrow("", "Null Report: No observations met the reporting criteria for inclusion in this output.") + ) +} diff --git a/man/null_report.Rd b/man/null_report.Rd new file mode 100644 index 00000000..23ddce05 --- /dev/null +++ b/man/null_report.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/null_report.R +\name{null_report} +\alias{null_report} +\title{Null report} +\usage{ +null_report() +} +\description{ +Null report +} +\details{ +This will create a null report similar as STREAM does. You can use +it inside output functions as shown in the example below. +} +\examples{ +library(dplyr) +library(filters) +data <- list( + adsl = eg_adsl, + adae = eg_adae \%>\% mutate(AREL = "") +) + +null_report() + +## An example how to use the `null_report()` inside an output function +t_ae <- function(datasets) { + trt <- "ACTARM" + anl <- semi_join( + datasets$adae, + datasets$adsl, + by = c("STUDYID", "USUBJID") + ) + + return(null_report()) +} + +data \%>\% + apply_filter("SER_SE") \%>\% + t_ae() + +} +\author{ +Thomas Neitmann (`neitmant`) +} diff --git a/tests/testthat/_snaps/t_dd_slide.md b/tests/testthat/_snaps/t_dd_slide.md index fd9589de..55495f38 100644 --- a/tests/testthat/_snaps/t_dd_slide.md +++ b/tests/testthat/_snaps/t_dd_slide.md @@ -1,8 +1,69 @@ +# Test table creation of t_dd_slide (death table) + + Code + t_dd_slide(testdata$adsl, "TRT01A") + Output + Death table + + ———————————————————————————————————————————————————————————————————————————————————————————————— + N (%) A: Drug X B: Placebo C: Combination All Patients All Patients + ———————————————————————————————————————————————————————————————————————————————————————————————— + All Deaths 25 (18.66%) 23 (17.16%) 22 (16.67%) 70 (17.50%) 70 (17.50%) + + Progressive Disease 8 (32%) 6 (26.1%) 6 (27.3%) 20 (28.6%) 20 (28.6%) + Adverse Events 9 (36%) 7 (30.4%) 10 (45.5%) 26 (37.1%) 26 (37.1%) + Other 8 (32%) 10 (43.5%) 6 (27.3%) 24 (34.3%) 24 (34.3%) + +--- + + Code + t_dd_slide(testdata$adsl, "TRT01A", split_by_study = TRUE) + Output + Death table + + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————— + AB12345-1 AB12345-2 + N (%) A: Drug X B: Placebo C: Combination A: Drug X B: Placebo C: Combination + ——————————————————————————————————————————————————————————————————————————————————————————————————————————————— + All Deaths 12 (19.35%) 13 (17.57%) 7 (10.94%) 13 (18.06%) 10 (16.67%) 15 (22.06%) + + Progressive Disease 4 (33.3%) 3 (23.1%) 3 (42.9%) 4 (30.8%) 3 (30%) 3 (20%) + Adverse Events 5 (41.7%) 5 (38.5%) 2 (28.6%) 4 (30.8%) 2 (20%) 8 (53.3%) + Other 3 (25%) 5 (38.5%) 2 (28.6%) 5 (38.5%) 5 (50%) 4 (26.7%) + +--- + + Code + t_dd_slide(testdata$adsl, "TRT01A", split_by_study = TRUE, side_by_side = TRUE) + Condition + Warning in `build_table_header()`: + split_by_study argument will be ignored + Output + Death table + + ————————————————————————————————————————————————————————————————————————————————— + N (%) A: Drug X B: Placebo C: Combination All Patients + ————————————————————————————————————————————————————————————————————————————————— + All Deaths 25 (18.66%) 23 (17.16%) 22 (16.67%) 70 (17.50%) + + Progressive Disease 8 (32%) 6 (26.1%) 6 (27.3%) 20 (28.6%) + Adverse Events 9 (36%) 7 (30.4%) 10 (45.5%) 26 (37.1%) + Other 8 (32%) 10 (43.5%) 6 (27.3%) 24 (34.3%) + # Test t_dd_slide table with expected Error Code t_dd_slide(adsl, "TRT") Condition - Error: - ! object 'adsl' not found + Error in `fix_one_split_var()`: + ! Split variable [TRT] not found in data being tabulated. + +# Test table creation of with null_report + + Code + t_dd_slide(testdata$adsl[0, ], "TRT01A") + Output + + ———————————————————————————————————————————————————————————————————————————————————————— + Null Report: No observations met the reporting criteria for inclusion in this output. diff --git a/tests/testthat/test-decorate.R b/tests/testthat/test-decorate.R index 44287c36..c8e85775 100755 --- a/tests/testthat/test-decorate.R +++ b/tests/testthat/test-decorate.R @@ -20,7 +20,7 @@ aa <- list(a, a) test_that("Test decoreate not to throw", { # test for decorate.autoslider_error - e <- autoslideR:::autoslider_error("error", list(program = "", suffix = ""), step = "test") + e <- autoslider_error("error", list(program = "", suffix = ""), step = "test") expect_no_error(decorate.autoslider_error(e)) # test for decorate.list From 03d6a796d66c0bf8057a83e10b81cc50991e3bc7 Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Wed, 13 Nov 2024 21:53:21 +0000 Subject: [PATCH 6/8] update tests --- R/t_dm_slide.R | 2 +- R/util.R | 13 ------ man/if_display_pp.Rd | 16 -------- man/t_dm_slide.Rd | 2 +- tests/testthat/test-save_output.R | 66 +++++++++++++++---------------- 5 files changed, 35 insertions(+), 64 deletions(-) delete mode 100644 man/if_display_pp.Rd diff --git a/R/t_dm_slide.R b/R/t_dm_slide.R index 3cb42894..1b7cbd5d 100755 --- a/R/t_dm_slide.R +++ b/R/t_dm_slide.R @@ -22,7 +22,7 @@ #' t_dm_slide <- function(adsl, arm = "TRT01P", - vars = c("AGEGR1", "SEX", "RACE", "BECOG", "BBMI"), + vars = c("AGE", "SEX", "RACE"), stats = c("median", "range", "count_fraction"), split_by_study = FALSE, side_by_side = NULL) { diff --git a/R/util.R b/R/util.R index 4821a99f..bc96f7fc 100755 --- a/R/util.R +++ b/R/util.R @@ -669,19 +669,6 @@ lyt_to_side_by_side_two_data <- function(lyt, anl, alt_counts_df, side_by_side = return(result) } -#' Checker of data frame display per patient (or not) -#' -#' @param pp per patient -#' @param colname name of column -if_display_pp <- function(pp, colname = FALSE) { - if (!pp) { - if (!colname) { - return("USUBJID") - } - return("Patient ID") - } - return(NULL) -} do_call <- function(fun, ...) { args <- list(...) diff --git a/man/if_display_pp.Rd b/man/if_display_pp.Rd deleted file mode 100644 index f408bcf3..00000000 --- a/man/if_display_pp.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/util.R -\name{if_display_pp} -\alias{if_display_pp} -\title{Checker of data frame display per patient (or not)} -\usage{ -if_display_pp(pp, colname = FALSE) -} -\arguments{ -\item{pp}{per patient} - -\item{colname}{name of column} -} -\description{ -Checker of data frame display per patient (or not) -} diff --git a/man/t_dm_slide.Rd b/man/t_dm_slide.Rd index ac65a55a..7f2d4bba 100644 --- a/man/t_dm_slide.Rd +++ b/man/t_dm_slide.Rd @@ -7,7 +7,7 @@ t_dm_slide( adsl, arm = "TRT01P", - vars = c("AGEGR1", "SEX", "RACE", "BECOG", "BBMI"), + vars = c("AGE", "SEX", "RACE"), stats = c("median", "range", "count_fraction"), split_by_study = FALSE, side_by_side = NULL diff --git a/tests/testthat/test-save_output.R b/tests/testthat/test-save_output.R index 300e3a74..548926cd 100755 --- a/tests/testthat/test-save_output.R +++ b/tests/testthat/test-save_output.R @@ -1,44 +1,44 @@ test_that("save an output", { - output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") + output <- t_dm_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") testthat::expect_no_error( save_output( output, - file_name = "t_ds_output", + file_name = "t_dm_output", save_rds = TRUE ) ) }) -test_that("Test save_output (Save an Output)", { - library(dplyr) - adsl <- eg_adsl %>% - mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) - adae <- eg_adae %>% - mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) - adae$ATOXGR <- adae$AETOXGR - output_dir <- tempdir() +# test_that("Test save_output (Save an Output)", { +# library(dplyr) +# adsl <- eg_adsl %>% +# mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) +# adae <- eg_adae %>% +# mutate(TRT01A = factor(TRT01A, levels = c("A: Drug X", "B: Placebo"))) +# adae$ATOXGR <- adae$AETOXGR +# output_dir <- tempdir() +# +# expect_snapshot(print(t_ae_pt_slide(adsl, adae, "TRT01A", 2) %>% +# decorate( +# title = "Serious Adverse Events, Safety-Evaluable Patients", +# footnote = "", +# paper = "P8", +# for_test = TRUE +# ) %>% +# save_output( +# file_name = file.path(output_dir, "t_ae_SER_SE"), +# save_rds = TRUE +# ))) +# }) - expect_snapshot(print(t_ae_pt_slide(adsl, adae, "TRT01A", 2) %>% - decorate( - title = "Serious Adverse Events, Safety-Evaluable Patients", - footnote = "", - paper = "P8", - for_test = TRUE - ) %>% - save_output( - file_name = file.path(output_dir, "t_ae_SER_SE"), - save_rds = TRUE - ))) -}) - -test_that("save an output", { - output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") - testthat::expect_no_error( - save_output( - output, - file_name = "t_ds_output", - save_rds = TRUE - ) - ) -}) +# test_that("save an output", { +# output <- t_ds_slide(adsl = testdata$adsl) %>% decorate(title = "test title", footnote = "") +# testthat::expect_no_error( +# save_output( +# output, +# file_name = "t_ds_output", +# save_rds = TRUE +# ) +# ) +# }) From 130e76c2f9cf443ad3cdcf3cc19b40bafadfb467 Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Wed, 13 Nov 2024 22:00:31 +0000 Subject: [PATCH 7/8] fix lintr --- R/save_output.R | 3 ++- R/t_ae_slide.R | 5 +++-- R/t_dm_slide.R | 10 ++++++---- R/util.R | 8 +------- tests/testthat/setup.R | 2 -- tests/testthat/test-data_snapshot.R | 4 +++- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/R/save_output.R b/R/save_output.R index e0917036..83f5e1be 100755 --- a/R/save_output.R +++ b/R/save_output.R @@ -11,7 +11,8 @@ #' #' @examples #' library(dplyr) -#' adsl <- eg_adsl %>% filter(SAFFL == "Y") %>% +#' adsl <- eg_adsl %>% +#' filter(SAFFL == "Y") %>% #' mutate(TRT01P = factor(TRT01P, levels = c("A: Drug X", "B: Placebo"))) #' output_dir <- tempdir() #' t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY")) %>% diff --git a/R/t_ae_slide.R b/R/t_ae_slide.R index 756249a9..de18d3dd 100755 --- a/R/t_ae_slide.R +++ b/R/t_ae_slide.R @@ -49,8 +49,9 @@ t_ae_slide <- function(adsl, adae, arm = "TRT01A", return(null_report()) } else { lyt <- build_table_header(adsl, arm, - split_by_study = split_by_study, - side_by_side = side_by_side) + split_by_study = split_by_study, + side_by_side = side_by_side + ) lyt <- lyt %>% split_rows_by( diff --git a/R/t_dm_slide.R b/R/t_dm_slide.R index 1b7cbd5d..a92c58cb 100755 --- a/R/t_dm_slide.R +++ b/R/t_dm_slide.R @@ -17,7 +17,8 @@ #' generate_slides(out1, "dm.pptx") #' #' out2 <- t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), -#' split_by_study = TRUE) +#' split_by_study = TRUE +#' ) #' print(out2) #' t_dm_slide <- function(adsl, @@ -39,8 +40,10 @@ t_dm_slide <- function(adsl, adsl1 <- adsl %>% select(all_of(c("STUDYID", "USUBJID", arm, vars, extra))) - lyt <- build_table_header(adsl1, arm, split_by_study = split_by_study, - side_by_side = side_by_side) + lyt <- build_table_header(adsl1, arm, + split_by_study = split_by_study, + side_by_side = side_by_side + ) lyt <- lyt %>% analyze_vars( @@ -55,7 +58,6 @@ t_dm_slide <- function(adsl, result <- lyt_to_side_by_side(lyt, adsl1, side_by_side) if (is.null(side_by_side)) { - # adding "N" attribute arm <- col_paths(result)[[1]][1] diff --git a/R/util.R b/R/util.R index bc96f7fc..01aba666 100755 --- a/R/util.R +++ b/R/util.R @@ -675,10 +675,6 @@ do_call <- function(fun, ...) { do.call(fun, args[intersect(names(args), formalArgs(fun))]) } -strip_NA <- function(input) { - return(input[which(input != "NA")]) -} - build_table_header <- function(anl, arm, @@ -709,7 +705,5 @@ build_table_header <- function(anl, get_version_label_output <- function() { - NULL + NULL } - - diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 49a917f4..f38b5f48 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -143,5 +143,3 @@ testdata_two_arm <- list( "adsl" = adsl_two_arm, "adae" = adae_two_arm ) - - diff --git a/tests/testthat/test-data_snapshot.R b/tests/testthat/test-data_snapshot.R index 190d8308..81667223 100755 --- a/tests/testthat/test-data_snapshot.R +++ b/tests/testthat/test-data_snapshot.R @@ -1,5 +1,7 @@ test_that("Test data snapshot", { - eg_dataname <- data(package = "autoslider.core")$results[, "Item"] %>% .[grep("eg_", .)] %>% sort + eg_dataname <- data(package = "autoslider.core")$results[, "Item"] %>% + .[grep("eg_", .)] %>% + sort() for (datai in eg_dataname) { expect_snapshot(dim(get(datai))) expect_snapshot(head(get(datai))) From bac477d84af94519ffbccdda18f5c45adc40a1a8 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:03:18 +0000 Subject: [PATCH 8/8] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/save_output.Rd | 3 ++- man/t_dm_slide.Rd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/man/save_output.Rd b/man/save_output.Rd index 7c211786..e72fb629 100644 --- a/man/save_output.Rd +++ b/man/save_output.Rd @@ -44,7 +44,8 @@ Tables are saved as RDS file } \examples{ library(dplyr) -adsl <- eg_adsl \%>\% filter(SAFFL == "Y") \%>\% +adsl <- eg_adsl \%>\% + filter(SAFFL == "Y") \%>\% mutate(TRT01P = factor(TRT01P, levels = c("A: Drug X", "B: Placebo"))) output_dir <- tempdir() t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY")) \%>\% diff --git a/man/t_dm_slide.Rd b/man/t_dm_slide.Rd index 7f2d4bba..745daf28 100644 --- a/man/t_dm_slide.Rd +++ b/man/t_dm_slide.Rd @@ -44,7 +44,8 @@ print(out1) generate_slides(out1, "dm.pptx") out2 <- t_dm_slide(adsl, "TRT01P", c("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY"), - split_by_study = TRUE) + split_by_study = TRUE +) print(out2) }