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

show_header_names() updates #1696

Open
ddsjoberg opened this issue May 30, 2024 · 1 comment
Open

show_header_names() updates #1696

ddsjoberg opened this issue May 30, 2024 · 1 comment
Assignees
Labels
v2.0 🤞🤞 A nice-to-have for the v2.0 release
Milestone

Comments

@ddsjoberg
Copy link
Owner

  • Do we still need the include_example argument?
  • The table is currently being printed with kable (aka a markdown table), if my memory is correct. I want to update this to be a {cli} print that is more beautiful, highlighting the parts that are most important, useful for users.
  • I also want to print the stats that are available to dynamically include in the headers (see example below), along with their types.
library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.7.2'

tbl <- tbl_summary(
  trial,
  by = trt, 
  include = age
) |> 
  add_overall()

show_header_names(tbl)
#> ℹ As a usage guide, the code below re-creates the current column headers.
#> modify_header(
#>   label = '**Characteristic**',
#>   stat_0 = '**Overall**, N = 200',
#>   stat_1 = '**Drug A**, N = 98',
#>   stat_2 = '**Drug B**, N = 102'
#> )
#> 
#> 
#> Column Name   Column Header        
#> ------------  ---------------------
#> label         **Characteristic**   
#> stat_0        **Overall**, N = 200 
#> stat_1        **Drug A**, N = 98   
#> stat_2        **Drug B**, N = 102

# i also want to be able to display what stats are available to report in the headers
#   AND the type (e.g. <int>, <dbl>, <chr>, etc.)
tbl$table_styling$header |> 
  dplyr::select(column, label, starts_with("modify_stat_")) |> 
  dplyr::rename_with(.fn = ~gsub("^modify_stat_", "", .x))
#> # A tibble: 8 × 6
#>   column    label                    N     n     p level  
#>   <chr>     <chr>                <int> <int> <dbl> <chr>  
#> 1 variable  variable               200    NA NA    <NA>   
#> 2 var_type  var_type               200    NA NA    <NA>   
#> 3 var_label var_label              200    NA NA    <NA>   
#> 4 row_type  row_type               200    NA NA    <NA>   
#> 5 label     **Characteristic**     200    NA NA    <NA>   
#> 6 stat_0    **Overall**, N = 200   200   200  1    Overall
#> 7 stat_1    **Drug A**, N = 98     200    98  0.49 Drug A 
#> 8 stat_2    **Drug B**, N = 102    200   102  0.51 Drug B

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

@ddsjoberg
Copy link
Owner Author

I think this example could be a good guide for designing something
https://mskcc-epi-bio.github.io/tidycmprsk/reference/crr.html

@ddsjoberg ddsjoberg added the v2.0 label May 31, 2024
@ddsjoberg ddsjoberg assigned ddsjoberg and ayogasekaram and unassigned ddsjoberg May 31, 2024
@ddsjoberg ddsjoberg added this to the v2.0.0 milestone Jun 23, 2024
@ddsjoberg ddsjoberg added v2.0 🤞🤞 A nice-to-have for the v2.0 release and removed v2.0 labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.0 🤞🤞 A nice-to-have for the v2.0 release
Projects
None yet
Development

No branches or pull requests

2 participants