Function to select labels from list of label pairs (format: age~"Age"
).
Alternative is to use attributes, eg from library(Hmisc)
.
Examples
vars<-c("hypertension", "diabetes", "mrs_1")
labels_all<-list(rtreat~"Trial treatment",
civil~"Cohabitation",
diabetes~"Known diabetes",
hypertension~"Known hypertension",
mrs_1~"One month mRS",
mrs_6~"Six months mRS",
'[Intercept]'~"Intercept")
label_select(labels_all,vars)
#> [[1]]
#> hypertension ~ "Known hypertension"
#> <environment: 0x562ba5cd5fc0>
#>
#> [[2]]
#> diabetes ~ "Known diabetes"
#> <environment: 0x562ba5cd5fc0>
#>
#> [[3]]
#> mrs_1 ~ "One month mRS"
#> <environment: 0x562ba5cd5fc0>
#>
## With gtsummary::tbl_summary()
#stRoke::talos[vars] |>
#gtsummary::tbl_summary(label = label_select(labels_all,vars))