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

Add option to place "Unknown" row at the top or bottom for categorical and continuous2 summary types #1952

Closed
ddsjoberg opened this issue Sep 4, 2024 · 2 comments

Comments

@ddsjoberg
Copy link
Owner

ddsjoberg commented Sep 4, 2024

This will be helpful because Roche often wants to report the number non missing at the top.

This would be included in either the brdg_() function or even a pier_*().

@ddsjoberg
Copy link
Owner Author

This would be a precursor to making it simpler to get a table like the one below that is common at Roche.

library(gtsummary)

trial |> 
  tbl_summary(
    include = c(response, grade, age), 
    type = list(c(response, grade) ~ "categorical", age ~ "continuous2"),
    missing = "always",
    missing_stat = "{N_nonmiss}",
    missing_text = "n"
  ) |> 
  modify_table_body(
    function(.x) .x |> 
      mutate(
        .by = variable,
        across(everything(), ~.[order(row_type != "label", row_type != "missing")])
      )
  ) |> 
  bold_labels() |> 
  as_kable()
Characteristic N = 200
Tumor Response
n 193
0 132 (68%)
1 61 (32%)
Grade
n 200
I 68 (34%)
II 68 (34%)
III 64 (32%)
Age
n 189
Median (Q1, Q3) 47 (38, 57)

Created on 2024-09-05 with reprex v2.1.0

@ddsjoberg
Copy link
Owner Author

Added a function to do this directly here: https://insightsengineering.github.io/crane/reference/tbl_demographics.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant