diff --git a/R/add_significance_stars.R b/R/add_significance_stars.R index 2ce28ee21..2e6fc9874 100644 --- a/R/add_significance_stars.R +++ b/R/add_significance_stars.R @@ -82,7 +82,7 @@ add_significance_stars <- function(x, # checking inputs ------------------------------------------------------------ check_not_missing(x) check_class(x, "gtsummary") - check_class(thresholds, "numeric") + check_class(thresholds, c("numeric", "integer")) check_range(thresholds, range = c(0, 1), include_bounds = c(TRUE, TRUE)) check_scalar_logical(hide_ci) check_scalar_logical(hide_p) diff --git a/R/tbl_survfit.R b/R/tbl_survfit.R index 9fdeabfad..607cdec08 100644 --- a/R/tbl_survfit.R +++ b/R/tbl_survfit.R @@ -110,6 +110,8 @@ tbl_survfit <- function(x, ...) { #' @export #' @rdname tbl_survfit tbl_survfit.survfit <- function(x, ...) { + set_cli_abort_call() + tbl_survfit.list(x = list(x), ...) } @@ -194,7 +196,7 @@ tbl_survfit.list <- function(x, predicate = \(x) inherits(x, "survfit"), error_msg = "The values passed in the {.cls list} from argument {.arg x} must be class {.cls survfit}." ) - check_class(times, "numeric", allow_empty = TRUE) + check_class(times, c("numeric", "integer"), allow_empty = TRUE) check_class(probs, "numeric", allow_empty = TRUE) if (is_empty(times) + is_empty(probs) != 1L) { cli::cli_abort( diff --git a/tests/testthat/test-tbl_survfit.R b/tests/testthat/test-tbl_survfit.R index 36698ce41..7ed5fdb4b 100644 --- a/tests/testthat/test-tbl_survfit.R +++ b/tests/testthat/test-tbl_survfit.R @@ -1,6 +1,6 @@ skip_on_cran() -test_that("tbl_survfit(time) works", { +test_that("tbl_survfit(times) works", { expect_silent( trial |> tbl_survfit( @@ -22,6 +22,17 @@ test_that("tbl_survfit(probs) works", { ) }) +test_that("tbl_survfit works with integer times values", { + expect_silent( + trial |> + tbl_survfit( + include = trt, + y = "Surv(ttdeath, death)", + times = c(6L, 12L) + ) + ) +}) + test_that("Using both times and probs errors correctly", { expect_error( trial |>