Search code examples
rgtsummarygt

Supress table header in tbl_regression of gtsummary


Update to clarify and show intention:

The related question is here tbl_merge: sort variables alphabetically in merged tbl_regression models {gtsummary} and @Daniel D. Sjoberg already provided the correct and professional answer.

But I want to try if this is possible:

x <- tbl_merge(list(t1, t2, t3 ,t4))

y <- x %>% 
  tbl_split(variables = c(age, ttdeath, response, death, stage, grade)) 

With this code I split the table into one row tables:

y[[1]]

enter image description here

y[[2]]

enter image description here

and so on.....

Now: I want to remove each footnote and header and merge them in a defined order together. In essence it is the reversal of spliting?!

Thanks for your time and energy!

First question:

With the tbl_regression() function from gtsummary we can make a table.

By adding modify_footnote(everything() ~ NA, abbreviation = TRUE) we can omit footnotes.

like here: from:supress confidence interval footnote in tbl_regression

library(dplyr)
library(gtsummary)

my_table <-
  lm(mpg ~ disp, mtcars) %>%
  tbl_regression(exponentiate = FALSE) %>%
  modify_footnote(everything() ~ NA, abbreviation = TRUE)
my_table

Result:

enter image description here

My question:

How can I remove the header part of this table to get this output:

enter image description here

If possible it should be possible with modify_header or modify_table_styling()?!

There is a rationale behind.

The ultimate goal is to split each element of a gtsummary table Split long gtsummary() table to n smaller tables and rearrange them in a given order tbl_merge: sort variables alphabetically in merged tbl_regression models {gtsummary}


Solution

  • Once you've split your table, you can re-assemble it with tbl_stack(). No need to worry about the headers and footnotes...they will work themselves out. tbl_stack(list(y[[2)]], y[[1)]]).