I am trying to make tables with both the SMD and the p value on the same table. First issue is add_p and add_difference cannot be in same table code without the error
`add_difference()` cannot be run after `add_p()`, and vice versa
Furthermore, the code for the SMD as it stands does not work with categorical variables. See code
library(gtsummary)
trial2 <- trial %>% select(trt, age, grade)
trial2 %>%
tbl_summary(by = trt) %>%
add_difference(list(all_continuous() ~ "cohens_d",
all_categorical() ~ "cohens_d")) %>%
add_overall() %>%
add_n() %>%
modify_header(label ~ "**Variable**") %>%
modify_spanning_header(c("stat_1", "stat_2") ~ "**Treatment Received**") %>%
modify_footnote(
all_stat_cols() ~ "Median (IQR) or Frequency (%)"
) %>%
modify_caption("**Table 1. Patient Characteristics**") %>%
bold_labels()
returns
Variable(s) 'grade' are summary type 'categorical' and not compatible with `add_difference()`.
could the SMD be calculated similar to the tableone package or using with ‘stddiff’ package so that it works with categorical variables?
