Use Variable Names as Labels
use_varnames_as_labels(data, caps = NULL, exclude = NULL)
a data frame
variables to be entirely capitalized
variables to exclude from labeling
a labeled data frame
library(gtsummary)
mtcars %>%
select(mpg, cyl, vs, am, carb) %>%
use_varnames_as_labels(caps = c(mpg, vs, am), exclude = cyl) %>%
tbl_summary() %>%
as_kable(format = "simple")
#>
#>
#> **Characteristic** **N = 32**
#> ------------------- -------------------
#> MPG 19.2 (15.4, 22.8)
#> cyl
#> 4 11 (34%)
#> 6 7 (22%)
#> 8 14 (44%)
#> VS 14 (44%)
#> AM 13 (41%)
#> Carb
#> 1 7 (22%)
#> 2 10 (31%)
#> 3 3 (9.4%)
#> 4 10 (31%)
#> 6 1 (3.1%)
#> 8 1 (3.1%)