From 06fdf0eb08ec05b9037e5d0ca83e089a0c9cf49f Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Tue, 11 Apr 2023 10:14:18 -0400 Subject: [PATCH 1/6] Fix tibble snapshots (#878) Closes #866 --- .../_snaps/abnormal_by_worst_grade_worsen.md | 126 ++++++------------ .../_snaps/h_map_for_count_abnormal.md | 113 ++++++---------- tests/testthat/_snaps/h_stack_by_baskets.md | 29 ++-- tests/testthat/_snaps/split_cols_by_groups.md | 10 +- .../test-abnormal_by_worst_grade_worsen.R | 16 +-- .../testthat/test-h_map_for_count_abnormal.R | 21 ++- tests/testthat/test-h_stack_by_baskets.R | 2 +- tests/testthat/test-split_cols_by_groups.R | 2 +- 8 files changed, 124 insertions(+), 195 deletions(-) diff --git a/tests/testthat/_snaps/abnormal_by_worst_grade_worsen.md b/tests/testthat/_snaps/abnormal_by_worst_grade_worsen.md index a463f03462..2ebf023f1b 100644 --- a/tests/testthat/_snaps/abnormal_by_worst_grade_worsen.md +++ b/tests/testthat/_snaps/abnormal_by_worst_grade_worsen.md @@ -3,47 +3,51 @@ Code res Output - # A tibble: 20 x 8 - # Groups: USUBJID, PARAMCD [15] - USUBJID PARAMCD VALUES MIN MAX WGRLOFL WGRHIFL GRADDR - - 1 4 ABC 0.0478 0.0478 187. "Y" "" Low - 2 3 OPQ 0.314 0.314 144. "Y" "" Low - 3 4 OPQ 0.455 0.455 193. "Y" "" Low - 4 2 ABC 0.790 0.790 181. "Y" "" Low - 5 2 OPQ 7.49 7.49 195. "Y" "" Low - 6 5 OPQ 22.7 22.7 187. "Y" "" Low - 7 1 OPQ 23.5 23.5 196. "Y" "" Low - 8 1 ABC 26.9 26.9 187. "Y" "" Low - 9 3 ABC 37.9 37.9 197. "Y" "" Low - 10 5 ABC 46.7 46.7 193. "Y" "" Low - 11 3 OPQ 144. 0.314 144. "" "Y" High - 12 3 XYZ 155. 17.1 155. "" "Y" High - 13 2 XYZ 157. 7.79 157. "" "Y" High - 14 4 XYZ 167. 0.276 167. "" "Y" High - 15 5 OPQ 187. 22.7 187. "" "Y" High - 16 5 XYZ 189. 16.1 189. "" "Y" High - 17 4 OPQ 193. 0.455 193. "" "Y" High - 18 2 OPQ 195. 7.49 195. "" "Y" High - 19 1 OPQ 196. 23.5 196. "" "Y" High - 20 1 XYZ 198. 16.5 198. "" "Y" High + USUBJID PARAMCD VALUES MIN MAX WGRLOFL WGRHIFL GRADDR + 1 4 ABC 0.04777932 0.04777932 186.6068 Y Low + 2 3 OPQ 0.31411084 0.31411084 143.8712 Y Low + 3 4 OPQ 0.45459322 0.45459322 192.5216 Y Low + 4 2 ABC 0.78966776 0.78966776 181.3203 Y Low + 5 2 OPQ 7.48620657 7.48620657 194.7080 Y Low + 6 5 OPQ 22.74372182 22.74372182 187.4772 Y Low + 7 1 OPQ 23.49747233 23.49747233 195.6453 Y Low + 8 1 ABC 26.93331945 26.93331945 187.4151 Y Low + 9 3 ABC 37.89478708 37.89478708 196.5634 Y Low + 10 5 ABC 46.70470511 46.70470511 192.5141 Y Low + 11 3 OPQ 143.87116753 0.31411084 143.8712 Y High + 12 3 XYZ 155.16467253 17.12241299 155.1647 Y High + 13 2 XYZ 156.93855514 7.78729822 156.9386 Y High + 14 4 XYZ 167.36031189 0.27616872 167.3603 Y High + 15 5 OPQ 187.47716993 22.74372182 187.4772 Y High + 16 5 XYZ 188.94406511 16.05289332 188.9441 Y High + 17 4 OPQ 192.52160275 0.45459322 192.5216 Y High + 18 2 OPQ 194.70798275 7.48620657 194.7080 Y High + 19 1 OPQ 195.64528568 23.49747233 195.6453 Y High + 20 1 XYZ 197.77834578 16.48751162 197.7783 Y High # h_adlb_worsen stacks data correctly Code res Output - # A tibble: 8 x 9 - USUBJID ARMCD AVISIT PARAMCD ATOXGR BTOXGR WGRLOFL WGRHIFL GRADDR - - 1 AB12345-CHN-1-id-53 ARM B WEEK ~ IGA 0 0 "" "Y" High - 2 AB12345-CHN-3-id-128 ARM B WEEK ~ IGA 4 0 "" "Y" High - 3 AB12345-CHN-1-id-53 ARM B WEEK ~ ALT 4 0 "" "Y" High - 4 AB12345-CHN-3-id-128 ARM B WEEK ~ ALT 1 0 "" "Y" High - 5 AB12345-CHN-1-id-53 ARM B WEEK ~ CRP 0 1 "Y" "Y" Low - 6 AB12345-CHN-3-id-128 ARM B WEEK ~ CRP 0 0 "Y" "" Low - 7 AB12345-CHN-1-id-53 ARM B WEEK ~ ALT -4 0 "Y" "" Low - 8 AB12345-CHN-3-id-128 ARM B WEEK ~ ALT -4 0 "Y" "" Low + USUBJID ARMCD AVISIT PARAMCD ATOXGR BTOXGR WGRLOFL + 1 AB12345-CHN-1-id-53 ARM B WEEK 1 DAY 8 IGA 0 0 + 2 AB12345-CHN-3-id-128 ARM B WEEK 5 DAY 36 IGA 4 0 + 3 AB12345-CHN-1-id-53 ARM B WEEK 3 DAY 22 ALT 4 0 + 4 AB12345-CHN-3-id-128 ARM B WEEK 4 DAY 29 ALT 1 0 + 5 AB12345-CHN-1-id-53 ARM B WEEK 3 DAY 22 CRP 0 1 Y + 6 AB12345-CHN-3-id-128 ARM B WEEK 1 DAY 8 CRP 0 0 Y + 7 AB12345-CHN-1-id-53 ARM B WEEK 5 DAY 36 ALT -4 0 Y + 8 AB12345-CHN-3-id-128 ARM B WEEK 5 DAY 36 ALT -4 0 Y + WGRHIFL GRADDR + 1 Y High + 2 Y High + 3 Y High + 4 Y High + 5 Y Low + 6 Low + 7 Low + 8 Low # h_worsen_counter counts data (low) correctly @@ -221,55 +225,3 @@ 4 7/69 (10.1%) 6/72 (8.3%) 4/55 (7.3%) Any 30/69 (43.5%) 26/72 (36.1%) 19/55 (34.5%) -# h_adlb_worsen all high - - Code - res - Output - # A tibble: 600 x 51 - STUDYID COUNTRY SITEID SUBJID AGE SEX ARMCD ARM ACTAR~1 ACTARM RACE - - 1 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug~ ARM A A: Dr~ ASIAN - 2 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug~ ARM A A: Dr~ ASIAN - 3 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug~ ARM A A: Dr~ ASIAN - 4 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 5 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 6 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 7 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 8 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 9 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 10 AB12345 BRA BRA-1 id-23 41.3 F ARM A A: Drug~ ARM A A: Dr~ AMER~ - # ... with 590 more rows, 40 more variables: TRTSDTM , TRTEDTM , - # EOSDY , STRATA1 , STRATA2 , BMRKR1 , BMRKR2 , - # REGION1 , SAFFL , USUBJID , PARAM , AVISIT , - # AVAL , LBCAT , PARAMCD , AVALU , AVISITN , - # ABLFL2 , ABLFL , BASE , BASETYPE , ANRIND , - # ANRLO , ANRHI , DTYPE , ATOXGR , BTOXGR , - # ATOXDSCL , ATOXDSCH , ADTM , ASPID , LBSEQ , ... - -# h_adlb_worsen all low - - Code - res - Output - # A tibble: 600 x 51 - STUDYID COUNTRY SITEID SUBJID AGE SEX ARMCD ARM ACTAR~1 ACTARM RACE - - 1 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug~ ARM A A: Dr~ ASIAN - 2 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug~ ARM A A: Dr~ ASIAN - 3 AB12345 BRA BRA-1 id-105 37.8 F ARM A A: Drug~ ARM A A: Dr~ ASIAN - 4 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 5 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 6 AB12345 BRA BRA-1 id-171 29.8 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 7 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 8 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 9 AB12345 BRA BRA-1 id-177 38.9 F ARM B B: Plac~ ARM B B: Pl~ ASIAN - 10 AB12345 BRA BRA-1 id-23 41.3 F ARM A A: Drug~ ARM A A: Dr~ AMER~ - # ... with 590 more rows, 40 more variables: TRTSDTM , TRTEDTM , - # EOSDY , STRATA1 , STRATA2 , BMRKR1 , BMRKR2 , - # REGION1 , SAFFL , USUBJID , PARAM , AVISIT , - # AVAL , LBCAT , PARAMCD , AVALU , AVISITN , - # ABLFL2 , ABLFL , BASE , BASETYPE , ANRIND , - # ANRLO , ANRHI , DTYPE , ATOXGR , BTOXGR , - # ATOXDSCL , ATOXDSCH , ADTM , ASPID , LBSEQ , ... - diff --git a/tests/testthat/_snaps/h_map_for_count_abnormal.md b/tests/testthat/_snaps/h_map_for_count_abnormal.md index a9dfb086bb..234177622e 100644 --- a/tests/testthat/_snaps/h_map_for_count_abnormal.md +++ b/tests/testthat/_snaps/h_map_for_count_abnormal.md @@ -3,113 +3,78 @@ Code res Output - # A tibble: 6 x 2 - # Groups: PARAM [2] PARAM ANRIND - - 1 ALT HIGH - 2 ALT LOW - 3 ALT NORMAL - 4 CPR HIGH - 5 CPR LOW - 6 CPR NORMAL + 1 ALT HIGH + 2 ALT LOW + 3 ALT NORMAL + 4 CPR HIGH + 5 CPR LOW + 6 CPR NORMAL # h_map_for_count_abnormal returns the correct map for range method with healthy single input Code res Output - # A tibble: 6 x 2 - # Groups: PARAM [2] PARAM ANRIND - - 1 ALT HIGH - 2 ALT LOW - 3 ALT NORMAL - 4 CPR HIGH - 5 CPR LOW - 6 CPR NORMAL + 1 ALT HIGH + 2 ALT LOW + 3 ALT NORMAL + 4 CPR HIGH + 5 CPR LOW + 6 CPR NORMAL # h_map_for_count_abnormal returns the correct map for default method with unused LOW LOW/HIGH HIGH input Code res Output - # A tibble: 6 x 2 - # Groups: PARAM [2] PARAM ANRIND - - 1 ALT HIGH - 2 ALT LOW - 3 ALT NORMAL - 4 CPR HIGH - 5 CPR LOW - 6 CPR NORMAL - ---- - - Code - res - Output - # A tibble: 7 x 2 - # Groups: PARAM [2] - PARAM ANRIND - - 1 ALT HIGH - 2 ALT LOW - 3 ALT LOW LOW - 4 ALT NORMAL - 5 CPR HIGH - 6 CPR LOW - 7 CPR NORMAL + 1 ALT HIGH + 2 ALT LOW + 3 ALT NORMAL + 4 CPR HIGH + 5 CPR LOW + 6 CPR NORMAL # h_map_for_count_abnormal returns the correct map for range method with unused LOW LOW/HIGH HIGH input Code res Output - # A tibble: 10 x 2 - # Groups: PARAM [2] - PARAM ANRIND - - 1 ALT HIGH - 2 ALT HIGH HIGH - 3 ALT LOW - 4 ALT LOW LOW - 5 ALT NORMAL - 6 CPR HIGH - 7 CPR HIGH HIGH - 8 CPR LOW - 9 CPR LOW LOW - 10 CPR NORMAL + PARAM ANRIND + 1 ALT HIGH + 2 ALT HIGH HIGH + 3 ALT LOW + 4 ALT LOW LOW + 5 ALT NORMAL + 6 CPR HIGH + 7 CPR HIGH HIGH + 8 CPR LOW + 9 CPR LOW LOW + 10 CPR NORMAL --- Code res Output - # A tibble: 6 x 2 - # Groups: PARAM [2] PARAM ANRIND - - 1 ALT HIGH - 2 ALT LOW - 3 ALT NORMAL - 4 CPR HIGH - 5 CPR LOW - 6 CPR NORMAL + 1 ALT HIGH + 2 ALT LOW + 3 ALT NORMAL + 4 CPR HIGH + 5 CPR LOW + 6 CPR NORMAL --- Code res Output - # A tibble: 4 x 2 - # Groups: PARAM [2] PARAM ANRIND - - 1 ALT HIGH - 2 ALT NORMAL - 3 CPR LOW - 4 CPR NORMAL + 1 ALT HIGH + 2 ALT NORMAL + 3 CPR LOW + 4 CPR NORMAL diff --git a/tests/testthat/_snaps/h_stack_by_baskets.md b/tests/testthat/_snaps/h_stack_by_baskets.md index 6e19985ee4..7dcbc98b6e 100644 --- a/tests/testthat/_snaps/h_stack_by_baskets.md +++ b/tests/testthat/_snaps/h_stack_by_baskets.md @@ -3,17 +3,24 @@ Code res Output - # A tibble: 8 x 6 - STUDYID USUBJID ASTDTM AEDECOD AESEQ SMQ - - 1 AB12345 AB12345-BRA-11-id-8 2021-12-05 02:02:07 dcd D.2.1.5.3 2 D.2.1.5~ - 2 AB12345 AB12345-BRA-12-id-120 2020-02-05 01:42:29 dcd D.2.1.5.3 2 D.2.1.5~ - 3 AB12345 AB12345-BRA-1-id-171 2022-11-29 12:18:31 dcd C.1.1.1.3 2 C.1.1.1~ - 4 AB12345 AB12345-BRA-1-id-23 2020-07-10 07:32:49 dcd B.2.2.3.1 3 C.1.1.1~ - 5 AB12345 AB12345-BRA-1-id-59 2021-10-10 23:54:46 dcd C.1.1.1.3 4 C.1.1.1~ - 6 AB12345 AB12345-BRA-1-id-9 2021-06-01 14:39:09 dcd C.1.1.1.3 1 C.1.1.1~ - 7 AB12345 AB12345-BRA-11-id-8 2021-12-21 02:02:07 dcd C.1.1.1.3 3 C.1.1.1~ - 8 AB12345 AB12345-BRA-12-id-120 2020-10-01 01:42:29 dcd C.1.1.1.3 3 C.1.1.1~ + STUDYID USUBJID ASTDTM AEDECOD AESEQ + 1 AB12345 AB12345-BRA-11-id-8 2021-12-05 02:02:07 dcd D.2.1.5.3 2 + 2 AB12345 AB12345-BRA-12-id-120 2020-02-05 01:42:29 dcd D.2.1.5.3 2 + 3 AB12345 AB12345-BRA-1-id-171 2022-11-29 12:18:31 dcd C.1.1.1.3 2 + 4 AB12345 AB12345-BRA-1-id-23 2020-07-10 07:32:49 dcd B.2.2.3.1 3 + 5 AB12345 AB12345-BRA-1-id-59 2021-10-10 23:54:46 dcd C.1.1.1.3 4 + 6 AB12345 AB12345-BRA-1-id-9 2021-06-01 14:39:09 dcd C.1.1.1.3 1 + 7 AB12345 AB12345-BRA-11-id-8 2021-12-21 02:02:07 dcd C.1.1.1.3 3 + 8 AB12345 AB12345-BRA-12-id-120 2020-10-01 01:42:29 dcd C.1.1.1.3 3 + SMQ + 1 D.2.1.5.3/A.1.1.1.1 aesi + 2 D.2.1.5.3/A.1.1.1.1 aesi + 3 C.1.1.1.3/B.2.2.3.1 aesi(BROAD) + 4 C.1.1.1.3/B.2.2.3.1 aesi(BROAD) + 5 C.1.1.1.3/B.2.2.3.1 aesi(BROAD) + 6 C.1.1.1.3/B.2.2.3.1 aesi(BROAD) + 7 C.1.1.1.3/B.2.2.3.1 aesi(BROAD) + 8 C.1.1.1.3/B.2.2.3.1 aesi(BROAD) # h_stack_by_baskets returns an empty dataframe with desired variables and labels when there are no adverse events falling within any of the baskets selected diff --git a/tests/testthat/_snaps/split_cols_by_groups.md b/tests/testthat/_snaps/split_cols_by_groups.md index 3a50a40cfc..c4d56a21ce 100644 --- a/tests/testthat/_snaps/split_cols_by_groups.md +++ b/tests/testthat/_snaps/split_cols_by_groups.md @@ -3,12 +3,10 @@ Code res Output - # A tibble: 3 x 4 - valname label levelcombo exargs - - 1 AnyGrade Any Grade (%) - 2 Grade34 Grade 3-4 (%) - 3 Grade5 Grade 5 (%) + valname label levelcombo exargs + 1 AnyGrade Any Grade (%) 1, 2, 3, 4, 5 NULL + 2 Grade34 Grade 3-4 (%) 3, 4 NULL + 3 Grade5 Grade 5 (%) 5 NULL # combine_groups combines character vectors diff --git a/tests/testthat/test-abnormal_by_worst_grade_worsen.R b/tests/testthat/test-abnormal_by_worst_grade_worsen.R index 6fe73b39df..d854586367 100644 --- a/tests/testthat/test-abnormal_by_worst_grade_worsen.R +++ b/tests/testthat/test-abnormal_by_worst_grade_worsen.R @@ -48,7 +48,7 @@ testthat::test_that("h_adlb_worsen stacks data correctly (simple case)", { direction_var = "GRADDR" ) - result <- result[order(result$VALUES), ] + result <- result[order(result$VALUES), ] %>% data.frame() p1 <- input_data %>% dplyr::filter(WGRLOFL == "Y" & GRADDR == "L") p2 <- input_data %>% dplyr::filter(WGRHIFL == "Y" & GRADDR == "H") @@ -74,7 +74,9 @@ testthat::test_that("h_adlb_worsen stacks data correctly", { direction_var = "GRADDR" ) - result <- result %>% dplyr::select(USUBJID, ARMCD, AVISIT, PARAMCD, ATOXGR, BTOXGR, WGRLOFL, WGRHIFL, GRADDR) + result <- result %>% + dplyr::select(USUBJID, ARMCD, AVISIT, PARAMCD, ATOXGR, BTOXGR, WGRLOFL, WGRHIFL, GRADDR) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -225,10 +227,9 @@ testthat::test_that("h_adlb_worsen all high", { worst_flag_high = c("WGRHIFL" = "Y"), direction_var = "GRADDR" ) - result <- result[order(result$USUBJID, result$AVISIT, result$PARAMCD), ] - res <- testthat::expect_silent(result) - testthat::expect_snapshot(res) + testthat::expect_true(all(result$WGRHIFL == "Y" & result$GRADDR == "High")) + testthat::expect_identical(nrow(result), 600L) }) testthat::test_that("h_adlb_worsen all low", { @@ -247,8 +248,7 @@ testthat::test_that("h_adlb_worsen all low", { worst_flag_low = c("WGRLOFL" = "Y"), direction_var = "GRADDR" ) - result <- result[order(result$USUBJID, result$AVISIT, result$PARAMCD), ] - res <- testthat::expect_silent(result) - testthat::expect_snapshot(res) + testthat::expect_true(all(result$WGRLOFL == "Y" & result$GRADDR == "Low")) + testthat::expect_identical(nrow(result), 600L) }) diff --git a/tests/testthat/test-h_map_for_count_abnormal.R b/tests/testthat/test-h_map_for_count_abnormal.R index ab44cc05a8..d257ff3a8c 100644 --- a/tests/testthat/test-h_map_for_count_abnormal.R +++ b/tests/testthat/test-h_map_for_count_abnormal.R @@ -20,7 +20,8 @@ testthat::test_that("h_map_for_count_abnormal returns the correct map for defaul # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -41,7 +42,8 @@ testthat::test_that("h_map_for_count_abnormal returns the correct map for range # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -62,7 +64,8 @@ testthat::test_that( # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -88,7 +91,8 @@ testthat::test_that( # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -114,7 +118,8 @@ testthat::test_that( # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -142,7 +147,8 @@ testthat::test_that( # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -169,7 +175,8 @@ testthat::test_that( # order of anl variable within the split_rows group because the order of split_rows is something we want to check result <- result %>% dplyr::group_by(PARAM) %>% - dplyr::arrange(ANRIND, .by_group = TRUE) + dplyr::arrange(ANRIND, .by_group = TRUE) %>% + data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) diff --git a/tests/testthat/test-h_stack_by_baskets.R b/tests/testthat/test-h_stack_by_baskets.R index 604bff96ba..7817c92323 100644 --- a/tests/testthat/test-h_stack_by_baskets.R +++ b/tests/testthat/test-h_stack_by_baskets.R @@ -2,7 +2,7 @@ adae_local <- tern_ex_adae[1:20, ] %>% df_explicit_na() testthat::test_that("h_stack_by_baskets returns the correct dataframe", { - result <- h_stack_by_baskets(df = adae_local) + result <- h_stack_by_baskets(df = adae_local) %>% data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) diff --git a/tests/testthat/test-split_cols_by_groups.R b/tests/testthat/test-split_cols_by_groups.R index c4d016cf44..7a1f615c8c 100644 --- a/tests/testthat/test-split_cols_by_groups.R +++ b/tests/testthat/test-split_cols_by_groups.R @@ -5,7 +5,7 @@ testthat::test_that("groups_list_to_df works as expected", { "Grade 3-4 (%)" = c("3", "4"), "Grade 5 (%)" = "5" ) - result <- groups_list_to_df(grade_groups) + result <- groups_list_to_df(grade_groups) %>% data.frame() res <- testthat::expect_silent(result) testthat::expect_snapshot(res) From c393c777e67ac310c100e5c1b646fd45877d868b Mon Sep 17 00:00:00 2001 From: edelarua Date: Tue, 11 Apr 2023 14:15:34 +0000 Subject: [PATCH 2/6] [skip actions] Bump version to 0.8.1.9004 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3a5210efe7..fab2d5a89d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.8.1.9003 -Date: 2023-04-02 +Version: 0.8.1.9004 +Date: 2023-04-11 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 255ef101ed..424bcd9854 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# tern 0.8.1.9003 +# tern 0.8.1.9004 ### Bug Fixes * Fixed missing label for `TRTEDTM` in `tern` datasets. From c231645f3e8bb0f12fdf28cb1c595aeb819edd28 Mon Sep 17 00:00:00 2001 From: Nolan Steed <56098440+Nolan-Steed@users.noreply.github.com> Date: Thu, 13 Apr 2023 08:13:39 -0400 Subject: [PATCH 3/6] 858 missing values vignette (#876) Fixes #858 --- R/df_explicit_na.R | 21 ++++++ man/df_explicit_na.Rd | 21 ++++++ vignettes/missing_values.Rmd | 140 +++++++++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 vignettes/missing_values.Rmd diff --git a/R/df_explicit_na.R b/R/df_explicit_na.R index d98a7e4ab2..8ddd7fb512 100644 --- a/R/df_explicit_na.R +++ b/R/df_explicit_na.R @@ -38,6 +38,7 @@ #' stringsAsFactors = FALSE #' ) #' +#' # Example 1 #' # Encode missing values in all character or factor columns. #' df_explicit_na(my_data) #' # Also convert logical columns to factor columns. @@ -45,6 +46,26 @@ #' # Encode missing values in a subset of columns. #' df_explicit_na(my_data, omit_columns = c("x", "y")) #' +#' # Example 2 +#' # Here we purposefully convert all `M` values to `NA` in the `SEX` variable. +#' # After running `df_explicit_na` the `NA` values are encoded as `` but they are not +#' # included when generating `rtables`. +#' adsl <- tern_ex_adsl +#' adsl$SEX[adsl$SEX == "M"] <- NA +#' adsl <- df_explicit_na(adsl) +#' +#' # If you want the `Na` values to be displayed in the table use the `na_level` argument. +#' adsl <- tern_ex_adsl +#' adsl$SEX[adsl$SEX == "M"] <- NA +#' adsl <- df_explicit_na(adsl, na_level = "Missing Values") +#' +#' # Example 3 +#' # Numeric variables that have missing values are not altered. This means that any `NA` value in +#' # a numeric variable will not be included in the summary statistics, nor will they be included +#' # in the denominator value for calculating the percent values. +#' adsl <- tern_ex_adsl +#' adsl$AGE[adsl$AGE < 30] <- NA +#' adsl <- df_explicit_na(adsl) df_explicit_na <- function(data, omit_columns = NULL, char_as_factor = TRUE, diff --git a/man/df_explicit_na.Rd b/man/df_explicit_na.Rd index 61eb63bf6c..d6f8d758f4 100644 --- a/man/df_explicit_na.Rd +++ b/man/df_explicit_na.Rd @@ -56,6 +56,7 @@ my_data <- data.frame( stringsAsFactors = FALSE ) +# Example 1 # Encode missing values in all character or factor columns. df_explicit_na(my_data) # Also convert logical columns to factor columns. @@ -63,6 +64,26 @@ df_explicit_na(my_data, logical_as_factor = TRUE) # Encode missing values in a subset of columns. df_explicit_na(my_data, omit_columns = c("x", "y")) +# Example 2 +# Here we purposefully convert all `M` values to `NA` in the `SEX` variable. +# After running `df_explicit_na` the `NA` values are encoded as `` but they are not +# included when generating `rtables`. +adsl <- tern_ex_adsl +adsl$SEX[adsl$SEX == "M"] <- NA +adsl <- df_explicit_na(adsl) + +# If you want the `Na` values to be displayed in the table use the `na_level` argument. +adsl <- tern_ex_adsl +adsl$SEX[adsl$SEX == "M"] <- NA +adsl <- df_explicit_na(adsl, na_level = "Missing Values") + +# Example 3 +# Numeric variables that have missing values are not altered. This means that any `NA` value in +# a numeric variable will not be included in the summary statistics, nor will they be included +# in the denominator value for calculating the percent values. +adsl <- tern_ex_adsl +adsl$AGE[adsl$AGE < 30] <- NA +adsl <- df_explicit_na(adsl) } \seealso{ \code{\link[=sas_na]{sas_na()}} and \code{\link[=explicit_na]{explicit_na()}} for other missing data helper functions. diff --git a/vignettes/missing_values.Rmd b/vignettes/missing_values.Rmd new file mode 100644 index 0000000000..cb28c4fef1 --- /dev/null +++ b/vignettes/missing_values.Rmd @@ -0,0 +1,140 @@ +--- +title: "Missing Values in Tern" +date: "2022-04-12" +output: + rmarkdown::html_document: + theme: "spacelab" + highlight: "kate" + toc: true + toc_float: true +vignette: > + %\VignetteIndexEntry{Missing Values in Tern} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +editor_options: + markdown: + wrap: 72 +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +The packages used in this vignette are: + +```{r, message=FALSE} +library(rtables) +library(formatters) +library(tern) +library(dplyr) +``` + +## Variable Class Conversion + +`rtables` requires that split variables to be factors. When you try and split a variable that +isn't, a warning message will appear. Here we purposefully convert the SEX variable to character +to demonstrate what happens when we try splitting the rows by this variable. To fix this, +`df_explict_na` will convert this to a factor resulting in the table being generated. + +```{r} +adsl <- tern_ex_adsl +adsl$SEX <- as.character(adsl$SEX) + +vars <- c("AGE", "SEX", "RACE", "BMRKR1") +var_labels <- c( + "Age (yr)", + "Sex", + "Race", + "Continous Level Biomarker 1" +) + +result <- basic_table(show_colcounts = TRUE) %>% + split_cols_by(var = "ARM") %>% + add_overall_col("All Patients") %>% + summarize_vars( + vars = vars, + var_labels = var_labels + ) %>% + build_table(adsl) +result +``` + +## Including Missing Values in `rtables` + +Here we purposefully convert all `M` values to `NA` in the `SEX` variable. +After running `df_explicit_na` the `NA` values are encoded as `` but they are not +included in the table. As well, the missing values are not included in the `n` count and they +are not included in the denominator value for calculating the percent values. + +```{r} +adsl <- tern_ex_adsl +adsl$SEX[adsl$SEX == "M"] <- NA +adsl <- df_explicit_na(adsl) + +vars <- c("AGE", "SEX") +var_labels <- c( + "Age (yr)", + "Sex" +) + +result <- basic_table(show_colcounts = TRUE) %>% + split_cols_by(var = "ARM") %>% + add_overall_col("All Patients") %>% + summarize_vars( + vars = vars, + var_labels = var_labels + ) %>% + build_table(adsl) +result +``` + +If you want the `Na` values to be displayed in the table and included in the `n` count +and as the denominator for calculating percent values, use the `na_level` argument. + +```{r} +adsl <- tern_ex_adsl +adsl$SEX[adsl$SEX == "M"] <- NA +adsl <- df_explicit_na(adsl, na_level = "Missing Values") + +result <- basic_table(show_colcounts = TRUE) %>% + split_cols_by(var = "ARM") %>% + add_overall_col("All Patients") %>% + summarize_vars( + vars = vars, + var_labels = var_labels + ) %>% + build_table(adsl) +result +``` + +## Missing Values in Numeric Variables + +Numeric variables that have missing values are not altered. This means that any `NA` value in +a numeric variable will not be included in the summary statistics, nor will they be included +in the denominator value for calculating the percent values. Here we make any value less than 30 +missing in the `AGE` variable and only the valued greater than 30 are included in the table below. + +```{r} +adsl <- tern_ex_adsl +adsl$AGE[adsl$AGE < 30] <- NA +adsl <- df_explicit_na(adsl) + +vars <- c("AGE", "SEX") +var_labels <- c( + "Age (yr)", + "Sex" +) + +result <- basic_table(show_colcounts = TRUE) %>% + split_cols_by(var = "ARM") %>% + add_overall_col("All Patients") %>% + summarize_vars( + vars = vars, + var_labels = var_labels + ) %>% + build_table(adsl) +result +``` From aa8075dd9c6a4373553be542f720e3304c86c2e8 Mon Sep 17 00:00:00 2001 From: Nolan-Steed Date: Thu, 13 Apr 2023 12:15:05 +0000 Subject: [PATCH 4/6] [skip actions] Bump version to 0.8.1.9005 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fab2d5a89d..607f9c96e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.8.1.9004 -Date: 2023-04-11 +Version: 0.8.1.9005 +Date: 2023-04-13 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 424bcd9854..b8627ef82c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# tern 0.8.1.9004 +# tern 0.8.1.9005 ### Bug Fixes * Fixed missing label for `TRTEDTM` in `tern` datasets. From 3ec400916f6ca75a4454d2580c96fcb124c4309b Mon Sep 17 00:00:00 2001 From: Davide Garolini Date: Wed, 19 Apr 2023 09:35:05 +0200 Subject: [PATCH 5/6] fixing argument convention and adding section_div to summarize_vars (#881) Fixes #879 --- NEWS.md | 1 + R/argument_convention.R | 6 ++++-- R/summarize_variables.R | 6 +++++- man/argument_convention.Rd | 7 +++++-- man/compare_variables.Rd | 4 ++-- man/count_cumulative.Rd | 4 ++-- man/count_missed_doses.Rd | 4 ++-- man/count_occurrences.Rd | 4 ++-- man/count_occurrences_by_grade.Rd | 2 +- man/count_patients_with_event.Rd | 4 ++-- man/estimate_multinomial_rsp.Rd | 2 +- man/estimate_proportions.Rd | 2 +- man/incidence_rate.Rd | 2 +- man/odds_ratio.Rd | 2 +- man/prop_diff.Rd | 4 ++-- man/prop_diff_test.Rd | 4 ++-- man/summarize_ancova.Rd | 4 ++-- man/summarize_glm_count.Rd | 4 ++-- man/summarize_num_patients.Rd | 2 +- man/summarize_variables.Rd | 9 +++++++-- man/survival_coxph_pairwise.Rd | 4 ++-- man/survival_time.Rd | 2 +- man/survival_timepoint.Rd | 4 ++-- 23 files changed, 51 insertions(+), 36 deletions(-) diff --git a/NEWS.md b/NEWS.md index b8627ef82c..68d8ae396b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ * Implemented the `lubridate` package for date variables in `tern` datasets. * Organization of `.gitignore` and `.Rbuildignore`. * Removed deprecated `footnotes` functions and all related files. +* Added `section_div` and `na_level` (`na_str`) to `summarize_vars`. # tern 0.8.0 diff --git a/R/argument_convention.R b/R/argument_convention.R index 4c090a67e5..31e4b4109b 100644 --- a/R/argument_convention.R +++ b/R/argument_convention.R @@ -49,11 +49,13 @@ #' Only considered if `draw = TRUE` is used. #' @param prune_zero_rows (`flag`)\cr whether to prune all zero rows. #' @param rsp (`logical`)\cr whether each subject is a responder or not. -#' @param show_labels label visibility: one of "default", "visible" and "hidden". +#' @param show_labels (`string`)\cr label visibility: one of "default", "visible" and "hidden". +#' @param section_div (`string`)\cr string which should be repeated as a section divider after each group +#' defined by this split instruction, or `NA_character_` (the default) for no section divider. #' @param table_names (`character`)\cr this can be customized in case that the same `vars` are analyzed multiple times, #' to avoid warnings from `rtables`. #' @param tte (`numeric`)\cr contains time-to-event duration values. -#' @param var_labels character for label. +#' @param var_labels (`character`)\cr character for label. #' @param variables (named `list` of `string`)\cr list of additional analysis variables. #' @param vars (`character`)\cr variable names for the primary analysis variable to be iterated over. #' @param var (`string`)\cr single variable name for the primary analysis variable. diff --git a/R/summarize_variables.R b/R/summarize_variables.R index 3b8e7472b1..a5179323a1 100644 --- a/R/summarize_variables.R +++ b/R/summarize_variables.R @@ -711,10 +711,12 @@ create_afun_summary <- function(.stats, .formats, .labels, .indent_mods) { summarize_vars <- function(lyt, vars, var_labels = vars, + na_level = NA_character_, nested = TRUE, ..., show_labels = "default", table_names = vars, + section_div = NA_character_, .stats = c("n", "mean_sd", "median", "range", "count_fraction"), .formats = NULL, .labels = NULL, @@ -726,10 +728,12 @@ summarize_vars <- function(lyt, vars = vars, var_labels = var_labels, afun = afun, + na_str = na_level, nested = nested, extra_args = list(...), inclNAs = TRUE, show_labels = show_labels, - table_names = table_names + table_names = table_names, + section_div = section_div ) } diff --git a/man/argument_convention.Rd b/man/argument_convention.Rd index fe712a41ed..843bc75542 100644 --- a/man/argument_convention.Rd +++ b/man/argument_convention.Rd @@ -73,14 +73,17 @@ Only considered if \code{draw = TRUE} is used.} \item{rsp}{(\code{logical})\cr whether each subject is a responder or not.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} + +\item{section_div}{(\code{string})\cr string which should be repeated as a section divider after each group +defined by this split instruction, or \code{NA_character_} (the default) for no section divider.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} \item{tte}{(\code{numeric})\cr contains time-to-event duration values.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} \item{variables}{(named \code{list} of \code{string})\cr list of additional analysis variables.} diff --git a/man/compare_variables.Rd b/man/compare_variables.Rd index 51722690ee..2bdf50a6f0 100644 --- a/man/compare_variables.Rd +++ b/man/compare_variables.Rd @@ -111,13 +111,13 @@ to print out information about factor casting.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} \item{nested}{(\code{flag})\cr whether this layout instruction be applied within the existing layout structure \emph{if possible} (\code{TRUE}, the default) or as a new top-level element (\code{FALSE}). Ignored if it would nest a split underneath analyses, which is not allowed.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/count_cumulative.Rd b/man/count_cumulative.Rd index 75dae47021..c32c1d3ad0 100644 --- a/man/count_cumulative.Rd +++ b/man/count_cumulative.Rd @@ -55,9 +55,9 @@ count, default is \code{TRUE}.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/count_missed_doses.Rd b/man/count_missed_doses.Rd index 3b24a3f407..65057347f8 100644 --- a/man/count_missed_doses.Rd +++ b/man/count_missed_doses.Rd @@ -38,9 +38,9 @@ count_missed_doses( \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{...}{additional arguments for the lower level functions.} diff --git a/man/count_occurrences.Rd b/man/count_occurrences.Rd index 486de0ceae..d12d0e4375 100644 --- a/man/count_occurrences.Rd +++ b/man/count_occurrences.Rd @@ -65,9 +65,9 @@ by a statistics function.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{...}{additional arguments for the lower level functions.} diff --git a/man/count_occurrences_by_grade.Rd b/man/count_occurrences_by_grade.Rd index fcb497d866..461692200b 100644 --- a/man/count_occurrences_by_grade.Rd +++ b/man/count_occurrences_by_grade.Rd @@ -73,7 +73,7 @@ in the the output list; in this case only the grade groups names will be include \item{var_labels}{(\code{character})\cr labels to show in the result table.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{...}{additional arguments for the lower level functions.} diff --git a/man/count_patients_with_event.Rd b/man/count_patients_with_event.Rd index a66b7742a8..88757ec5b0 100644 --- a/man/count_patients_with_event.Rd +++ b/man/count_patients_with_event.Rd @@ -114,9 +114,9 @@ variables from analysis dataset used for counting the number of unique identifie \item{var}{(\code{string})\cr single variable name that is passed by \code{rtables} when requested by a statistics function.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} } \value{ \code{\link[=s_count_patients_with_event]{s_count_patients_with_event()}} returns the count and fraction of patients with the diff --git a/man/estimate_multinomial_rsp.Rd b/man/estimate_multinomial_rsp.Rd index 351b35ee4c..72aee3063b 100644 --- a/man/estimate_multinomial_rsp.Rd +++ b/man/estimate_multinomial_rsp.Rd @@ -36,7 +36,7 @@ estimate_multinomial_response( \item{var}{(\code{string})\cr single variable name that is passed by \code{rtables} when requested by a statistics function.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/estimate_proportions.Rd b/man/estimate_proportions.Rd index e792a1ee89..9e95891aa7 100644 --- a/man/estimate_proportions.Rd +++ b/man/estimate_proportions.Rd @@ -77,7 +77,7 @@ to find estimates of optimal weights.} \item{...}{other arguments are ultimately conveyed to \code{\link[=s_proportion]{s_proportion()}}.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/incidence_rate.Rd b/man/incidence_rate.Rd index 0c51d68cc3..9e853e47e6 100644 --- a/man/incidence_rate.Rd +++ b/man/incidence_rate.Rd @@ -62,7 +62,7 @@ indicating time unit for data input. \item{...}{additional arguments for the lower level functions.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/odds_ratio.Rd b/man/odds_ratio.Rd index 9ced4d1db2..1531efe6ed 100644 --- a/man/odds_ratio.Rd +++ b/man/odds_ratio.Rd @@ -66,7 +66,7 @@ levels that belong to it in the character vectors that are elements of the list. \item{...}{arguments passed to \code{s_odds_ratio()}.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/prop_diff.Rd b/man/prop_diff.Rd index 26a2728105..79e768a8aa 100644 --- a/man/prop_diff.Rd +++ b/man/prop_diff.Rd @@ -69,9 +69,9 @@ and directs the way weights are estimated.} \item{...}{arguments passed to \code{s_proportion_diff()}.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/prop_diff_test.Rd b/man/prop_diff_test.Rd index 91a94291af..7686f45bdc 100644 --- a/man/prop_diff_test.Rd +++ b/man/prop_diff_test.Rd @@ -59,9 +59,9 @@ to calculate the p-value.} \item{...}{other arguments are passed to \code{\link[=s_test_proportion_diff]{s_test_proportion_diff()}}.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/summarize_ancova.Rd b/man/summarize_ancova.Rd index 7f4202de1b..7fccd93489 100644 --- a/man/summarize_ancova.Rd +++ b/man/summarize_ancova.Rd @@ -72,11 +72,11 @@ with arm. if the interaction is not needed, the default option is NULL.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} \item{...}{additional arguments for the lower level functions.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/summarize_glm_count.Rd b/man/summarize_glm_count.Rd index 6159fe7a7d..1d3653da8a 100644 --- a/man/summarize_glm_count.Rd +++ b/man/summarize_glm_count.Rd @@ -67,11 +67,11 @@ by a statistics function.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} \item{...}{additional arguments for the lower level functions.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/summarize_num_patients.Rd b/man/summarize_num_patients.Rd index 59a13d769c..3a698fb20b 100644 --- a/man/summarize_num_patients.Rd +++ b/man/summarize_num_patients.Rd @@ -87,7 +87,7 @@ unmodified default behavior.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} } \value{ A list with: diff --git a/man/summarize_variables.Rd b/man/summarize_variables.Rd index af37392a48..29aac0a222 100644 --- a/man/summarize_variables.Rd +++ b/man/summarize_variables.Rd @@ -109,10 +109,12 @@ summarize_vars( lyt, vars, var_labels = vars, + na_level = NA_character_, nested = TRUE, ..., show_labels = "default", table_names = vars, + section_div = NA_character_, .stats = c("n", "mean_sd", "median", "range", "count_fraction"), .formats = NULL, .labels = NULL, @@ -160,17 +162,20 @@ to print out information about factor casting.} \item{vars}{(\code{character})\cr variable names for the primary analysis variable to be iterated over.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} \item{nested}{(\code{flag})\cr whether this layout instruction be applied within the existing layout structure \emph{if possible} (\code{TRUE}, the default) or as a new top-level element (\code{FALSE}). Ignored if it would nest a split underneath analyses, which is not allowed.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} +\item{section_div}{(\code{string})\cr string which should be repeated as a section divider after each group +defined by this split instruction, or \code{NA_character_} (the default) for no section divider.} + \item{.stats}{(\code{character})\cr statistics to select for the table.} \item{.formats}{(named \code{character} or \code{list})\cr formats for the statistics.} diff --git a/man/survival_coxph_pairwise.Rd b/man/survival_coxph_pairwise.Rd index 6cef5d0fe2..fff4d11338 100644 --- a/man/survival_coxph_pairwise.Rd +++ b/man/survival_coxph_pairwise.Rd @@ -70,9 +70,9 @@ can also be set to "breslow" or "exact". See more in \code{\link[survival:coxph] \item{...}{additional arguments for the lower level functions.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/survival_time.Rd b/man/survival_time.Rd index 0aa69d6b0c..5a09ad04c2 100644 --- a/man/survival_time.Rd +++ b/man/survival_time.Rd @@ -46,7 +46,7 @@ see more in \code{\link[survival:survfit]{survival::survfit()}}. Note option "no \item{...}{additional arguments for the lower level functions.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} \item{table_names}{(\code{character})\cr this can be customized in case that the same \code{vars} are analyzed multiple times, to avoid warnings from \code{rtables}.} diff --git a/man/survival_timepoint.Rd b/man/survival_timepoint.Rd index ea7d6b484c..5cf1074636 100644 --- a/man/survival_timepoint.Rd +++ b/man/survival_timepoint.Rd @@ -92,9 +92,9 @@ see more in \code{\link[survival:survfit]{survival::survfit()}}. Note option "no \item{table_names_suffix}{(\code{string})\cr optional suffix for the \code{table_names} used for the \code{rtables} to avoid warnings from duplicate table names.} -\item{var_labels}{character for label.} +\item{var_labels}{(\code{character})\cr character for label.} -\item{show_labels}{label visibility: one of "default", "visible" and "hidden".} +\item{show_labels}{(\code{string})\cr label visibility: one of "default", "visible" and "hidden".} \item{method}{(\code{string})\cr either \code{surv} (survival estimations), \code{surv_diff} (difference in survival with the control) or \code{both}.} From a4d11918735aae429b0c49f065df6f967feba5cc Mon Sep 17 00:00:00 2001 From: Melkiades Date: Wed, 19 Apr 2023 07:36:25 +0000 Subject: [PATCH 6/6] [skip actions] Bump version to 0.8.1.9006 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 607f9c96e3..a33e956864 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.8.1.9005 -Date: 2023-04-13 +Version: 0.8.1.9006 +Date: 2023-04-19 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 68d8ae396b..a66713377d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# tern 0.8.1.9005 +# tern 0.8.1.9006 ### Bug Fixes * Fixed missing label for `TRTEDTM` in `tern` datasets.