Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tbl_ard_summary() with mixed-type by variables has unintuitive results: check for mixed type and message users? #2000

Open
ddsjoberg opened this issue Sep 25, 2024 · 1 comment
Milestone

Comments

@ddsjoberg
Copy link
Owner

library(survival)
library(cards)
library(gtsummary)
packageVersion("cards")
#> [1] '0.2.2.9009'

bind_ard(
  ard_continuous(trial, variables = age, by = trt),
  survfit(Surv(ttdeath, death) ~ trt, trial) |> 
    cardx::ard_survival_survfit(times = c(12, 24)) |> 
    dplyr::mutate(context = "categorical") # this will no loner be needed later (handled in another issue)
) |> 
  tbl_ard_summary(
    by = trt,
    statistic = time ~ "{estimate}% (95% CI {conf.low}%, {conf.high}%)"
  ) |> 
  as_kable()
Characteristic Drug A Drug B 1 2
age 46.0 (37.0, 60.0) 48.0 (39.0, 56.0)
time
12 0.9% (95% CI 0.9%, 1.0%) 0.9% (95% CI 0.8%, 0.9%)
24 0.5% (95% CI 0.4%, 0.6%) 0.4% (95% CI 0.3%, 0.5%)

Created on 2024-09-25 with reprex v2.1.1

@ddsjoberg ddsjoberg modified the milestones: v2.1.0, v2.0.3 Sep 25, 2024
@ddsjoberg
Copy link
Owner Author

So.....this is actually correct behaviour. The survival results convert the trt levels to factors, and as such, they are being recognized as different levels.

But if I found this confusing, then others will as well. I wonder if there is some kind of message we could pass to users, if the by levels are mixed type?? 🤔

@ddsjoberg ddsjoberg modified the milestones: v2.0.3, v2.1.0 Sep 26, 2024
@ddsjoberg ddsjoberg changed the title tbl_ard_summary() with standard and non-standard data sources doesn't assign columns properly tbl_ard_summary() with mixed-type by variables has unintuitive results: check for mixed type and message users? Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant