diff --git a/DESCRIPTION b/DESCRIPTION index 6ab961ebb..3839a677f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9027 +Version: 0.1.0.9028 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 8464b2800..27ee17f65 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9027 +# cardx 0.1.0.9028 ### Breaking Changes diff --git a/tests/testthat/_snaps/ard_car_vif.md b/tests/testthat/_snaps/ard_car_vif.md index 8d0a7a74b..4f3b5ac9d 100644 --- a/tests/testthat/_snaps/ard_car_vif.md +++ b/tests/testthat/_snaps/ard_car_vif.md @@ -20,27 +20,12 @@ 1 BMIBL car_vif VIF VIF 1.010522 1 NULL NULL 2 EDUCLVL car_vif VIF VIF 1.010522 1 NULL NULL -# ard_car_vif() appropriate errors are given for model with only 1 term - - Code - as.data.frame(ard_car_vif(lm(AGE ~ ARM, data = cards::ADSL))) - Output - variable context stat_name stat_label stat fmt_fn warning - 1 ARM car_vif VIF VIF NULL NULL NULL - 2 ARM car_vif GVIF GVIF NULL NULL NULL - 3 ARM car_vif aGVIF Adjusted GVIF NULL NULL NULL - 4 ARM car_vif df df NULL NULL NULL - error - 1 model contains fewer than 2 terms - 2 model contains fewer than 2 terms - 3 model contains fewer than 2 terms - 4 model contains fewer than 2 terms - # ard_vif() issues friendly messaging for incorrect object passed in/can't get terms of model Code - ard_vif(cards::ADSL) + ard_car_vif(cards::ADSL) Condition - Error in `ard_vif()`: - ! could not find function "ard_vif" + Error in `ard_car_vif()`: + ! There was an error running `car::vif()`. See below. + x no applicable method for 'vcov' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')" diff --git a/tests/testthat/_snaps/ard_effectsize_cohens_d.md b/tests/testthat/_snaps/ard_effectsize_cohens_d.md index 6cd20d5a2..f7a81921d 100644 --- a/tests/testthat/_snaps/ard_effectsize_cohens_d.md +++ b/tests/testthat/_snaps/ard_effectsize_cohens_d.md @@ -1,21 +1,5 @@ # ard_effectsize_cohens_d() works - Code - as.data.frame(dplyr::select(ard_effectsize_cohens_d(cards::ADSL, by = ARM, - variables = AGE), c("variable", "stat_name", "error"))) - Output - variable stat_name error - 1 AGE estimate Grouping variable y must have exactly 2 levels. - 2 AGE conf.level Grouping variable y must have exactly 2 levels. - 3 AGE conf.low Grouping variable y must have exactly 2 levels. - 4 AGE conf.high Grouping variable y must have exactly 2 levels. - 5 AGE mu Grouping variable y must have exactly 2 levels. - 6 AGE paired Grouping variable y must have exactly 2 levels. - 7 AGE pooled_sd Grouping variable y must have exactly 2 levels. - 8 AGE alternative Grouping variable y must have exactly 2 levels. - ---- - Code as.data.frame(dplyr::slice_head(dplyr::group_by(dplyr::select( ard_effectsize_cohens_d(dplyr::filter(cards::ADSL, ARM %in% c("Placebo", @@ -30,20 +14,3 @@ 5 ARM HEIGHTBL effectsize_cohens_d CI Confidence Level 0.95 6 ARM HEIGHTBL effectsize_cohens_d CI Lower Bound -0.600975 -# ard_effectsize_paired_cohens_d() works - - Code - as.data.frame(dplyr::select(ard_effectsize_paired_cohens_d(dplyr::mutate( - ADSL_paired, ARM = ifelse(dplyr::row_number() == 1L, "3rd ARM", ARM)), by = ARM, - variable = AGE, id = USUBJID), c("variable", "stat_name", "error"))) - Output - variable stat_name error - 1 AGE estimate The `by` argument must have two and only two levels. - 2 AGE conf.level The `by` argument must have two and only two levels. - 3 AGE conf.low The `by` argument must have two and only two levels. - 4 AGE conf.high The `by` argument must have two and only two levels. - 5 AGE mu The `by` argument must have two and only two levels. - 6 AGE paired The `by` argument must have two and only two levels. - 7 AGE pooled_sd The `by` argument must have two and only two levels. - 8 AGE alternative The `by` argument must have two and only two levels. - diff --git a/tests/testthat/_snaps/ard_effectsize_hedges_g.md b/tests/testthat/_snaps/ard_effectsize_hedges_g.md index e06a4ae16..51de3474b 100644 --- a/tests/testthat/_snaps/ard_effectsize_hedges_g.md +++ b/tests/testthat/_snaps/ard_effectsize_hedges_g.md @@ -1,21 +1,5 @@ # ard_effectsize_hedges_g() works - Code - as.data.frame(dplyr::select(ard_effectsize_hedges_g(cards::ADSL, by = ARM, - variable = AGE), c("variable", "stat_name", "error"))) - Output - variable stat_name error - 1 AGE estimate Grouping variable y must have exactly 2 levels. - 2 AGE conf.level Grouping variable y must have exactly 2 levels. - 3 AGE conf.low Grouping variable y must have exactly 2 levels. - 4 AGE conf.high Grouping variable y must have exactly 2 levels. - 5 AGE mu Grouping variable y must have exactly 2 levels. - 6 AGE paired Grouping variable y must have exactly 2 levels. - 7 AGE pooled_sd Grouping variable y must have exactly 2 levels. - 8 AGE alternative Grouping variable y must have exactly 2 levels. - ---- - Code as.data.frame(dplyr::slice_head(dplyr::group_by(dplyr::select( ard_effectsize_hedges_g(dplyr::filter(cards::ADSL, ARM %in% c("Placebo", @@ -30,20 +14,3 @@ 5 ARM HEIGHTBL effectsize_hedges_g CI Confidence Level 0.95 6 ARM HEIGHTBL effectsize_hedges_g CI Lower Bound -0.5982873 -# ard_effectsize_paired_hedges_g() works - - Code - as.data.frame(dplyr::select(ard_effectsize_paired_hedges_g(dplyr::mutate( - ADSL_paired, ARM = ifelse(dplyr::row_number() == 1L, "3rd ARM", ARM)), by = ARM, - variable = AGE, id = USUBJID), c("variable", "stat_name", "error"))) - Output - variable stat_name error - 1 AGE estimate The `by` argument must have two and only two levels. - 2 AGE conf.level The `by` argument must have two and only two levels. - 3 AGE conf.low The `by` argument must have two and only two levels. - 4 AGE conf.high The `by` argument must have two and only two levels. - 5 AGE mu The `by` argument must have two and only two levels. - 6 AGE paired The `by` argument must have two and only two levels. - 7 AGE pooled_sd The `by` argument must have two and only two levels. - 8 AGE alternative The `by` argument must have two and only two levels. - diff --git a/tests/testthat/_snaps/ard_stats_t_test.md b/tests/testthat/_snaps/ard_stats_t_test.md deleted file mode 100644 index 0b378d374..000000000 --- a/tests/testthat/_snaps/ard_stats_t_test.md +++ /dev/null @@ -1,75 +0,0 @@ -# ard_stats_t_test() works - - Code - as.data.frame(ard_stats_t_test(cards::ADSL, by = ARM, variable = AGE, - var.equal = TRUE)) - Output - group1 variable context stat_name stat_label stat fmt_fn - 1 ARM AGE stats_t_test estimate Mean Difference NULL NULL - 2 ARM AGE stats_t_test estimate1 Group 1 Mean NULL NULL - 3 ARM AGE stats_t_test estimate2 Group 2 Mean NULL NULL - 4 ARM AGE stats_t_test statistic t Statistic NULL NULL - 5 ARM AGE stats_t_test p.value p-value NULL NULL - 6 ARM AGE stats_t_test parameter Degrees of Freedom NULL NULL - 7 ARM AGE stats_t_test conf.low CI Lower Bound NULL NULL - 8 ARM AGE stats_t_test conf.high CI Upper Bound NULL NULL - 9 ARM AGE stats_t_test method method NULL NULL - 10 ARM AGE stats_t_test alternative alternative NULL NULL - 11 ARM AGE stats_t_test mu H0 Mean 0 1 - 12 ARM AGE stats_t_test paired Paired t-test FALSE NULL - 13 ARM AGE stats_t_test var.equal Equal Variances TRUE NULL - 14 ARM AGE stats_t_test conf.level CI Confidence Level 0.95 1 - warning error - 1 NULL grouping factor must have exactly 2 levels - 2 NULL grouping factor must have exactly 2 levels - 3 NULL grouping factor must have exactly 2 levels - 4 NULL grouping factor must have exactly 2 levels - 5 NULL grouping factor must have exactly 2 levels - 6 NULL grouping factor must have exactly 2 levels - 7 NULL grouping factor must have exactly 2 levels - 8 NULL grouping factor must have exactly 2 levels - 9 NULL grouping factor must have exactly 2 levels - 10 NULL grouping factor must have exactly 2 levels - 11 NULL grouping factor must have exactly 2 levels - 12 NULL grouping factor must have exactly 2 levels - 13 NULL grouping factor must have exactly 2 levels - 14 NULL grouping factor must have exactly 2 levels - -# ard_stats_paired_t_test() works - - Code - as.data.frame(ard_stats_paired_t_test(dplyr::mutate(ADSL_paired, ARM = ifelse( - dplyr::row_number() == 1L, "3rd ARM", ARM)), by = ARM, variable = AGE, id = USUBJID, - var.equal = TRUE)) - Output - group1 variable context stat_name stat_label stat fmt_fn - 1 ARM AGE stats_t_test estimate Mean Difference NULL NULL - 2 ARM AGE stats_t_test estimate1 Group 1 Mean NULL NULL - 3 ARM AGE stats_t_test estimate2 Group 2 Mean NULL NULL - 4 ARM AGE stats_t_test statistic t Statistic NULL NULL - 5 ARM AGE stats_t_test p.value p-value NULL NULL - 6 ARM AGE stats_t_test parameter Degrees of Freedom NULL NULL - 7 ARM AGE stats_t_test conf.low CI Lower Bound NULL NULL - 8 ARM AGE stats_t_test conf.high CI Upper Bound NULL NULL - 9 ARM AGE stats_t_test method method NULL NULL - 10 ARM AGE stats_t_test alternative alternative NULL NULL - 11 ARM AGE stats_t_test mu H0 Mean 0 1 - 12 ARM AGE stats_t_test paired Paired t-test TRUE NULL - 13 ARM AGE stats_t_test var.equal Equal Variances TRUE NULL - 14 ARM AGE stats_t_test conf.level CI Confidence Level 0.95 1 - warning error - 1 NULL The `by` argument must have two and only two levels. - 2 NULL The `by` argument must have two and only two levels. - 3 NULL The `by` argument must have two and only two levels. - 4 NULL The `by` argument must have two and only two levels. - 5 NULL The `by` argument must have two and only two levels. - 6 NULL The `by` argument must have two and only two levels. - 7 NULL The `by` argument must have two and only two levels. - 8 NULL The `by` argument must have two and only two levels. - 9 NULL The `by` argument must have two and only two levels. - 10 NULL The `by` argument must have two and only two levels. - 11 NULL The `by` argument must have two and only two levels. - 12 NULL The `by` argument must have two and only two levels. - 13 NULL The `by` argument must have two and only two levels. - 14 NULL The `by` argument must have two and only two levels. - diff --git a/tests/testthat/test-ard_car_vif.R b/tests/testthat/test-ard_car_vif.R index 390fdb77f..34ea2df7b 100644 --- a/tests/testthat/test-ard_car_vif.R +++ b/tests/testthat/test-ard_car_vif.R @@ -15,18 +15,12 @@ test_that("ard_car_vif() works", { }) test_that("ard_car_vif() appropriate errors are given for model with only 1 term", { - expect_snapshot( - lm(AGE ~ ARM, data = cards::ADSL) |> - ard_car_vif() |> - as.data.frame() - ) expect_equal( lm(AGE ~ ARM, data = cards::ADSL) |> ard_car_vif() |> - dplyr::select(error) |> - unlist() |> - unique(), - "model contains fewer than 2 terms" + dplyr::select(error) %>% + is.null(), + FALSE ) }) @@ -34,6 +28,6 @@ test_that("ard_car_vif() appropriate errors are given for model with only 1 term test_that("ard_vif() issues friendly messaging for incorrect object passed in/can't get terms of model", { expect_snapshot( error = TRUE, - cards::ADSL |> ard_vif() + cards::ADSL |> ard_car_vif() ) }) diff --git a/tests/testthat/test-ard_effectsize_cohens_d.R b/tests/testthat/test-ard_effectsize_cohens_d.R index fe5c771bf..cf846afe0 100644 --- a/tests/testthat/test-ard_effectsize_cohens_d.R +++ b/tests/testthat/test-ard_effectsize_cohens_d.R @@ -26,11 +26,12 @@ test_that("ard_effectsize_cohens_d() works", { ) # errors are properly handled - expect_snapshot( + expect_equal( cards::ADSL |> ard_effectsize_cohens_d(by = ARM, variables = AGE) |> - dplyr::select(c("variable", "stat_name", "error")) |> - as.data.frame() + dplyr::select(error) %>% + is.null(), + FALSE ) # test that the function works with multiple variables @@ -83,13 +84,14 @@ test_that("ard_effectsize_paired_cohens_d() works", { ) # errors are properly handled - expect_snapshot( + expect_equal( ADSL_paired |> dplyr::mutate( ARM = ifelse(dplyr::row_number() == 1L, "3rd ARM", ARM) ) |> ard_effectsize_paired_cohens_d(by = ARM, variable = AGE, id = USUBJID) |> - dplyr::select(c("variable", "stat_name", "error")) |> - as.data.frame() + dplyr::select(error) %>% + is.null(), + FALSE ) }) diff --git a/tests/testthat/test-ard_effectsize_hedges_g.R b/tests/testthat/test-ard_effectsize_hedges_g.R index 47f84ed93..3bd0024e0 100644 --- a/tests/testthat/test-ard_effectsize_hedges_g.R +++ b/tests/testthat/test-ard_effectsize_hedges_g.R @@ -24,11 +24,12 @@ test_that("ard_effectsize_hedges_g() works", { ) # errors are properly handled - expect_snapshot( + expect_equal( cards::ADSL |> ard_effectsize_hedges_g(by = ARM, variable = AGE) |> - dplyr::select(c("variable", "stat_name", "error")) |> - as.data.frame() + dplyr::select(error) %>% + is.null(), + FALSE ) # test that the function works with multiple variables as once @@ -83,13 +84,14 @@ test_that("ard_effectsize_paired_hedges_g() works", { ) # errors are properly handled - expect_snapshot( + expect_equal( ADSL_paired |> dplyr::mutate( ARM = ifelse(dplyr::row_number() == 1L, "3rd ARM", ARM) ) |> ard_effectsize_paired_hedges_g(by = ARM, variable = AGE, id = USUBJID) |> - dplyr::select(c("variable", "stat_name", "error")) |> - as.data.frame() + dplyr::select(error) %>% + is.null(), + FALSE ) }) diff --git a/tests/testthat/test-ard_stats_t_test.R b/tests/testthat/test-ard_stats_t_test.R index 15bb29a2d..9e487906a 100644 --- a/tests/testthat/test-ard_stats_t_test.R +++ b/tests/testthat/test-ard_stats_t_test.R @@ -44,10 +44,12 @@ test_that("ard_stats_t_test() works", { ) # errors are properly handled - expect_snapshot( + expect_equal( cards::ADSL |> ard_stats_t_test(by = ARM, variable = AGE, var.equal = TRUE) |> - as.data.frame() + dplyr::select(error) %>% + is.null(), + FALSE ) # test that the function works with multiple variables at once @@ -102,12 +104,14 @@ test_that("ard_stats_paired_t_test() works", { ) # errors are properly handled - expect_snapshot( + expect_equal( ADSL_paired |> dplyr::mutate( ARM = ifelse(dplyr::row_number() == 1L, "3rd ARM", ARM) ) |> ard_stats_paired_t_test(by = ARM, variable = AGE, id = USUBJID, var.equal = TRUE) |> - as.data.frame() + dplyr::select(error) %>% + is.null(), + FALSE ) })