'How to modify text in tbl_summary?
I'd like to modify, in tbl_summary "Median (IQR)" by "median [Q1 : Q3]", and "Range" by "Min -Max" ?
I'd like that in the far left colomn, we'd read "median [Q1 : Q3]" instead of "Median (IQR)"
trial %>% select(trt, age) %>%
tbl_summary(by = trt,
type = list(all_continuous() ~ "continuous2",
all_categorical() ~ "categorical"),
statistic = list(all_continuous()~ c("{N_nonmiss}",
"{min} - {max}",
"{mean} ({sd})",
"{median} [{p25} - {p75}]")))
Solution 1:[1]
You can use the add_stat_label() function from the same package.
library(gtsummary)
trial |>
select(trt, age) |>
tbl_summary(by = trt,
type = list(all_continuous() ~ "continuous2",
all_categorical() ~ "categorical"),
statistic = list(all_continuous() ~ c("{N_nonmiss}",
"{min} - {max}",
"{mean} ({sd})",
"{median} [{p25} - {p75}]"))) |>
add_stat_label(label = list(all_continuous() ~ c("N",
"Min - Max",
"Mean (SD)",
"Median [Q1 : Q3]")))
See the documentation for more info.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
