Consider the example below:
library(tidyverse)
library(gtsummary)
t1 <- trial %>%
na.exclude() %>%
lm(marker ~ age + ttdeath, .) %>%
tbl_regression()
t2 <- trial %>%
na.exclude() %>%
lm(marker ~ age + response + death, .) %>%
tbl_regression()
t3 <- trial %>%
na.exclude() %>%
lm(marker ~ age + stage + death, .) %>%
tbl_regression()
t4 <- trial %>%
na.exclude() %>%
lm(marker ~ stage + grade + death, .) %>%
tbl_regression()
tbl_merge(list(t1, t2, t3 ,t4))
In the characteristic tab, variables are only alphabetically within a particular model. For example, when looking only at Table 1 is fine, it's A-M-T.
However, when looking at mutiple tables at once, the order is not alphabetical. Is there a way to sort variables alphabetically within all the tables?
E.g. Age, Grade, Months to Death/Censor, Patient Died...
I assume the way to do this is by gtsummary::modify_table_body
into dplyr::arrange
,
but I don't know how to do it exactly.
Any help would be appreciated. Thanks in advance.
Edit: actually, anyway to manually modify the order of variables would be helpful as well, ignore this if it's too difficult.
Edit2: I forgot to mention that there's glance statistics involved as well, such as add_glance_table(adj.r.squared) %>% modify_table_body(~.x %>% arrange(row_type == "glance_statistic"))
(which is not in this example), so I imagine there is a possibility that the sorting of variables messes with the order of glance statistics as well. Excuse me for making this complicated, but it would be extremely helpful.