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
Asked
Active
Viewed 636 times
1 Answers
1
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)

Daniel D. Sjoberg
- 8,820
- 2
- 12
- 28
-
This answer worked for me after installing the "smd" R package. – R. Joe Sep 18 '22 at 05:09