Reputation: 21
The gtsummary::tbl_summary functionality is wonderful and I am looking for a way to add SMD for categorical variables. The tableone function provided smd for all types of covariates including character. I tried adding SMD to tbl_summary by add_stat with effsize::cohen.d or effsize::cohen.d. but both worked for numeric covariates and not for character. Any guidance is appreciated. Thanks
Upvotes: 2
Views: 1840
Reputation: 11774
Use the add_difference()
function with method "smd"
to get the standardized mean differences. Review this page for a list of all available methods https://www.danieldsjoberg.com/gtsummary/reference/tests.html
library(gtsummary)
#> #Uighur
packageVersion("gtsummary")
#> [1] '1.5.2'
tbl <-
trial %>%
select(trt, age, response, grade) %>%
tbl_summary(by = trt, missing = "no") %>%
add_difference(everything() ~ "smd")
Created on 2022-03-03 by the reprex package (v2.0.1)
Upvotes: 1