Hello @fefortti!
The tbl_summary()
function makes it's best guess whether each column in your data frame is continuous, categorical, or dichotomous. The default statistics displayed are based on this initial guess. If the function defaulted to an incorrect type, you can use the type=
argument to change it. I think in your case, tbl_summary()
guessed type categorical, when you were expecting continuous.
For more details on how the type is determined, see the help file Create a table of summary statistics — tbl_summary • gtsummary
From your code example, it looks to me like you want all the columns summarized as a continuous variable (using median and IQR), and to compare the groups with the Wilcoxon Rank Sum test. The first step I would take is to assign all types to continuous, and then everything else should work itself out with the defaults. (The default test for continuous variables is Wilcoxon.)
If this suggestion does not solve your problem, please provide an example I can run on my machine (aka a reprex), and I can perhaps help further.
Happy Coding!
library(gtsummary)
trial %>%
# selecting the continuous variables only
dplyr::select(age, marker, trt) %>%
# summarizing data by treatment type, all variables are continuous
tbl_summary(by = trt, type = everything() ~ "continuous") %>%
# comparing treatment groups
add_p()