Skip to content

Commit 8afe913

Browse files
committed
type conversion
1 parent 9a245a6 commit 8afe913

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* Added function `ard_incidence_rate()` to calculate ARDs for incidence rate estimation. (#234)
44

5+
* Fix in `ard_survival_survfit.data.frame()` method where the stratifying variable was not correctly converted back to its original type.
6+
57
# cardx 0.2.4
68

79
## New Features and Updates

R/ard_continuous.survey.design.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ accepted_svy_stats <- function(expand_quantiles = TRUE) {
376376

377377
ard_nested <- ard |>
378378
tidyr::nest(..ard_data... = -c(cards::all_ard_groups(), cards::all_ard_variables())) |>
379-
dplyr::arrange(across(c(cards::all_ard_groups(), cards::all_ard_variables()), unlist))
379+
dplyr::arrange(across(c(cards::all_ard_groups(), cards::all_ard_variables()),
380+
~ map(., as.character) |> unlist()))
380381

381382
# if all columns match, then replace the coerced character cols with their original type/class
382383
all_cols_equal <-

tests/testthat/test-ard_survival_survfit.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,24 @@ test_that("ard_survival_survfit.data.frame() works as expected", {
276276
class(),
277277
class(mtcars$vs)
278278
)
279+
280+
# adding another check type
281+
expect_silent(
282+
tbl <-
283+
ard_survival_survfit(
284+
x = cards::ADTTE,
285+
variables = "TRTA",
286+
y = "survival::Surv(time = AVAL, event = 1 - CNSR, type = 'right', origin = 0)",
287+
times = c(6, 12)
288+
)
289+
)
290+
expect_equal(
291+
cards::rename_ard_columns(tbl) |>
292+
dplyr::pull("TRTA") |>
293+
class(),
294+
class(cards::ADTTE$TRTA)
295+
)
296+
279297
})
280298

281299
test_that("ard_survival_survfit.data.frame(variables=NULL) for unstratified model", {

0 commit comments

Comments
 (0)