From f5616ea18d9a6fad1e7d5ab8fe46a031b5f85f7d Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Tue, 8 Oct 2024 20:34:30 +0800 Subject: [PATCH] Update DESCRIPTION (#1321) use survival 3.6-4 # Pull Request Fixes #nnn Signed-off-by: Joe Zhu --- DESCRIPTION | 2 +- tests/testthat/test-odds_ratio.R | 90 +++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5ea0bd0216..3817fc1c69 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,7 +48,7 @@ Imports: rlang (>= 1.1.0), scales (>= 1.2.0), stats, - survival (>= 3.7-0), + survival (>= 3.6-4), tibble (>= 2.0.0), tidyr (>= 0.8.3), utils diff --git a/tests/testthat/test-odds_ratio.R b/tests/testthat/test-odds_ratio.R index 0a00b93866..6ab89bbe5c 100644 --- a/tests/testthat/test-odds_ratio.R +++ b/tests/testthat/test-odds_ratio.R @@ -30,7 +30,11 @@ testthat::test_that("or_clogit estimates right OR and CI", { stringsAsFactors = TRUE ) - result <- or_clogit(data, conf_level = 0.95) + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + result <- or_clogit(data, conf_level = 0.95) + ) # from SAS res <- testthat::expect_silent(result) @@ -62,13 +66,17 @@ testthat::test_that("s_odds_ratio estimates right OR and CI (stratified analysis strata = factor(sample(c("C", "D"), 100, TRUE)) ) - result <- s_odds_ratio( - df = subset(dta, grp == "A"), - .var = "rsp", - .ref_group = subset(dta, grp == "B"), - .in_ref_col = FALSE, - .df_row = dta, - variables = list(arm = "grp", strata = "strata") + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + result <- s_odds_ratio( + df = subset(dta, grp == "A"), + .var = "rsp", + .ref_group = subset(dta, grp == "B"), + .in_ref_col = FALSE, + .df_row = dta, + variables = list(arm = "grp", strata = "strata") + ) ) res <- testthat::expect_silent(result) @@ -86,15 +94,19 @@ testthat::test_that("s_odds_ratio returns error for incorrect groups", { "Arms A+B" = c("A", "B") ) - testthat::expect_error(result <- s_odds_ratio( - df = subset(data, grp == "A"), - .var = "rsp", - .ref_group = subset(data, grp == "B"), - .in_ref_col = FALSE, - .df_row = data, - variables = list(arm = "grp", strata = "strata"), - groups_list = groups - )) + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + result <- testthat::expect_error(s_odds_ratio( + df = subset(data, grp == "A"), + .var = "rsp", + .ref_group = subset(data, grp == "B"), + .in_ref_col = FALSE, + .df_row = data, + variables = list(arm = "grp", strata = "strata"), + groups_list = groups + )) + ) }) testthat::test_that("estimate_odds_ratio estimates right OR and CI (unstratified analysis)", { @@ -120,10 +132,14 @@ testthat::test_that("estimate_odds_ratio estimates right OR and CI (stratified a strata = factor(sample(c("C", "D"), 100, TRUE)) ) - result <- basic_table() %>% - split_cols_by(var = "grp", ref_group = "A", split_fun = ref_group_position("first")) %>% - estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata")) %>% - build_table(df = data) + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + result <- basic_table() %>% + split_cols_by(var = "grp", ref_group = "A", split_fun = ref_group_position("first")) %>% + estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata")) %>% + build_table(df = data) + ) res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -154,7 +170,11 @@ testthat::test_that("estimate_odds_ratio works with strata and combined groups", groups_list = groups ) - result <- build_table(lyt = lyt, df = anl) + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + result <- build_table(lyt = lyt, df = anl) + ) res <- testthat::expect_silent(result) testthat::expect_snapshot(res) @@ -172,14 +192,18 @@ testthat::test_that("s_odds_ratio method argument works", { stringsAsFactors = TRUE ) - res <- s_odds_ratio( - df = subset(dta, grp == "A"), - .var = "rsp", - .ref_group = subset(dta, grp == "B"), - .in_ref_col = FALSE, - .df_row = dta, - variables = list(arm = "grp", strata = "strata"), - method = "approximate" + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + res <- s_odds_ratio( + df = subset(dta, grp == "A"), + .var = "rsp", + .ref_group = subset(dta, grp == "B"), + .in_ref_col = FALSE, + .df_row = dta, + variables = list(arm = "grp", strata = "strata"), + method = "approximate" + ) ) testthat::expect_false(all(is.na(res$or_ci))) @@ -213,7 +237,11 @@ testthat::test_that("estimate_odds_ratio method argument works", { split_cols_by(var = "grp", ref_group = "B") %>% estimate_odds_ratio(vars = "rsp", variables = list(arm = "grp", strata = "strata"), method = "approximate") - result <- build_table(lyt, df = dta) + # https://github.com/therneau/survival/issues/240 + withr::with_options( + opts_partial_match_old, + result <- build_table(lyt, df = dta) + ) res <- testthat::expect_silent(result) testthat::expect_snapshot(res)