Skip to content

Commit

Permalink
Merge b831b9a into 6e47e58
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo authored Jun 27, 2024
2 parents 6e47e58 + b831b9a commit 5197a88
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# tern 0.9.5.9001

### Bug Fixes
* Fixed a bug in `a_surv_time` that threw an error when split only has `"is_event"`.

# tern 0.9.5

### Enhancements
Expand Down
6 changes: 3 additions & 3 deletions R/survival_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ a_surv_time <- function(df,

cell_fns <- setNames(vector("list", length = length(x_stats)), .labels)
if ("range" %in% names(x_stats) && ref_fn_censor) {
if (x_stats[["range"]][1] == rng_censor_lwr && x_stats[["range"]][2] == rng_censor_upr) {
if (identical(x_stats[["range"]][1], rng_censor_lwr) && identical(x_stats[["range"]][2], rng_censor_upr)) {
cell_fns[[.labels[["range"]]]] <- "Censored observations: range minimum & maximum"
} else if (x_stats[["range"]][1] == rng_censor_lwr) {
} else if (identical(x_stats[["range"]][1], rng_censor_lwr)) {
cell_fns[[.labels[["range"]]]] <- "Censored observation: range minimum"
} else if (x_stats[["range"]][2] == rng_censor_upr) {
} else if (identical(x_stats[["range"]][2], rng_censor_upr)) {
cell_fns[[.labels[["range"]]]] <- "Censored observation: range maximum"
}
}
Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-survival_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,27 @@ testthat::test_that("surv_time works with referential footnotes", {
res <- testthat::expect_silent(result)
testthat::expect_snapshot(res)
})

testthat::test_that("a_surv_time works when `is_event` only has TRUE observations", {
anl <- tibble::tribble(
~AVAL, ~ARM, ~is_event,
1, "A", TRUE,
2, "A", TRUE
)

testthat::expect_silent(
tern::a_surv_time(anl, .var = "AVAL", is_event = "is_event")
)
})

testthat::test_that("a_surv_time works when `is_event` only has FALSE observations", {
anl <- tibble::tribble(
~AVAL, ~ARM, ~is_event,
1, "A", FALSE,
2, "A", FALSE
)

testthat::expect_silent(
tern::a_surv_time(anl, .var = "AVAL", is_event = "is_event")
)
})

0 comments on commit 5197a88

Please sign in to comment.