diff --git a/DESCRIPTION b/DESCRIPTION index 3cad397..142f960 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tidycmprsk Title: Competing Risks Estimation -Version: 1.0.0.9000 +Version: 1.0.0.9001 Authors@R: c( person(c("Daniel", "D."), "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-0862-2018")), @@ -16,7 +16,7 @@ License: AGPL (>= 3) URL: https://mskcc-epi-bio.github.io/tidycmprsk/, https://github.com/MSKCC-Epi-Bio/tidycmprsk BugReports: https://github.com/MSKCC-Epi-Bio/tidycmprsk/issues Depends: - R (>= 3.4) + R (>= 4.2) Imports: broom (>= 1.0.1), cli (>= 3.1.0), diff --git a/tests/testthat/_snaps/gtsummary_s3_methods.md b/tests/testthat/_snaps/gtsummary_s3_methods.md new file mode 100644 index 0000000..4bf676f --- /dev/null +++ b/tests/testthat/_snaps/gtsummary_s3_methods.md @@ -0,0 +1,25 @@ +# tbl_regression.tidycrr() + + Code + as.data.frame(tbl_regression(crr(Surv(ttdeath, death_cr) ~ age + grade, trial))) + Output + 11 cases omitted due to missing values + **Characteristic** **log(HR)** **95% CI** **p-value** + 1 Age 0.01 -0.01, 0.03 0.6 + 2 Grade + 3 I + 4 II 0.06 -0.65, 0.77 0.9 + 5 III 0.43 -0.20, 1.1 0.2 + +# global_pvalue_fun.tidycrr() + + Code + as.data.frame(tbl, col_labels = FALSE) + Output + label estimate conf.low p.value + 1 Age 0.01 -0.01, 0.03 0.6 + 2 Grade 0.3 + 3 I + 4 II 0.06 -0.65, 0.77 + 5 III 0.43 -0.20, 1.1 + diff --git a/tests/testthat/test-gtsummary_s3_methods.R b/tests/testthat/test-gtsummary_s3_methods.R new file mode 100644 index 0000000..e5294bf --- /dev/null +++ b/tests/testthat/test-gtsummary_s3_methods.R @@ -0,0 +1,26 @@ +test_that("tbl_regression.tidycrr()", { + expect_snapshot( + crr(Surv(ttdeath, death_cr) ~ age + grade, trial) |> + tbl_regression() |> + as.data.frame() + ) +}) + +test_that("global_pvalue_fun.tidycrr()", { + mod <- crr(Surv(ttdeath, death_cr) ~ age + grade, trial) + expect_error( + tbl <- mod |> + tbl_regression() |> + gtsummary::add_global_p(), + NA + ) + expect_snapshot(tbl |> as.data.frame(col_labels = FALSE)) + + expect_equal( + tbl$table_body$p.value[1:2], + cardx::ard_aod_wald_test(mod) |> + dplyr::filter(stat_name %in% "p.value") |> + dplyr::pull(stat) |> + unlist() + ) +})