diff --git a/DESCRIPTION b/DESCRIPTION index e1cd3dc..5fd63bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rifttable Type: Package Title: Results Tables to Bridge the Rift Between Epidemiologists and Their Data -Version: 0.7.1 +Version: 0.7.2 Authors@R: person(given = "Konrad H.", family = "Stopsack", @@ -19,7 +19,7 @@ License: GPL (>= 3) Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 Depends: R (>= 4.1.0) Imports: diff --git a/NEWS.md b/NEWS.md index 24f12dd..8de018f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# rifttable 0.7.2 + +* Bug fixes: + + `survdiff_ci()` now uses the `conf.level` argument correctly in confidence + interval estimation using the MOVER approach (#8). +* Internal: + + Anticipate changes in {dplyr} 1.2.0 in label handling in unit tests (thanks + to @DavisVaughan, #10). + + # rifttable 0.7.1 * Housekeeping for CRAN release diff --git a/R/survdiff_ci.R b/R/survdiff_ci.R index 1dd7bad..f917296 100644 --- a/R/survdiff_ci.R +++ b/R/survdiff_ci.R @@ -121,7 +121,8 @@ survdiff_ci <- function( formula = formula, data = data, id = .id, - weights = .weights + weights = .weights, + conf.int = conf.level ), time = time, extend = TRUE diff --git a/tests/testthat/test-missing_data.R b/tests/testthat/test-missing_data.R index 066243f..9e34190 100644 --- a/tests/testthat/test-missing_data.R +++ b/tests/testthat/test-missing_data.R @@ -2,9 +2,19 @@ data("breastcancer", package = "risks") df <- breastcancer |> dplyr::mutate( continuous = 1:dplyr::n(), - receptor = dplyr::if_else(dplyr::row_number() %in% 9:11, NA, receptor), + receptor = { + label <- attr(receptor, "label") + receptor <- dplyr::if_else(dplyr::row_number() %in% 9:11, NA, receptor) + attr(receptor, "label") <- label + receptor + }, stage = dplyr::if_else(dplyr::row_number() %in% 29:31, NA, stage), - death = dplyr::if_else(dplyr::row_number() %in% 99:101, NA, death), + death = { + label <- attr(death, "label") + death <- dplyr::if_else(dplyr::row_number() %in% 99:101, NA, death) + attr(death, "label") <- label + death + }, allempty = NA_real_, allempty_lgl = allempty == 1 ) diff --git a/tests/testthat/test-table1_design.R b/tests/testthat/test-table1_design.R index c3308cc..68f6ff1 100644 --- a/tests/testthat/test-table1_design.R +++ b/tests/testthat/test-table1_design.R @@ -2,8 +2,18 @@ data("breastcancer", package = "risks") df <- breastcancer |> dplyr::mutate( continuous = 1:dplyr::n(), - receptor = dplyr::if_else(dplyr::row_number() %in% 9:11, NA, receptor), - death = dplyr::if_else(dplyr::row_number() %in% 99:101, NA, death), + receptor = { + label <- attr(receptor, "label") + receptor <- dplyr::if_else(dplyr::row_number() %in% 9:11, NA, receptor) + attr(receptor, "label") <- label + receptor + }, + death = { + label <- attr(death, "label") + death <- dplyr::if_else(dplyr::row_number() %in% 99:101, NA, death) + attr(death, "label") <- label + death + }, allempty = NA_integer_, allempty_lgl = allempty == 1 ) diff --git a/tests/testthat/test-time2.R b/tests/testthat/test-time2.R index a858b6c..304e98a 100644 --- a/tests/testthat/test-time2.R +++ b/tests/testthat/test-time2.R @@ -201,6 +201,50 @@ testthat::test_that( ) +testthat::test_that( + desc = "cum inc difference does not ignore confidence level", + code = { + result <- survdiff_ci( + formula = survival::Surv( + time = time, + event = status + ) ~ + sex, + data = cancer, + time = 365.25 + ) + + result09 <- survdiff_ci( + formula = survival::Surv( + time = time, + event = status + ) ~ + sex, + data = cancer, + time = 365.25, + conf.level = 0.9 + ) + + expect_gt( + object = result09$conf.low, + expected = result$conf.low + ) + expect_lt( + object = result09$conf.high, + expected = result$conf.high + ) + expect_equal( + object = result09$estimate, + expected = result$estimate + ) + expect_equal( + object = result09$std.error, + expected = result$std.error, + tolerance = 0.01 + ) + } +) + testthat::test_that( desc = "Invalid ID variable is found", code = {