0

I tried to run the Kruskal Wallis test for multiple variables at once, but I couldn't. I want to display the mean±SD in the table instead of the median(IQR) similar to what in this image

enter image description here

Here is my data:



df1<- data.frame(Age=c(25,35,24,34,19,20,28,31),
Gender=c("F","M","M","M","F","M","F","F"),
Year_study=c("final","first","second","first","third","second","fourth","first"),
D_score=c(22,25,35,16,32,22,41,19))


print(df1)

I tried this loop:

cols<- names(df1)[1:3]
 all<- lapply(cols, function(x)kruskal.test(reformulate("D_score",x), data=df1))
 all

But I can't convert it to table using gtsummary

I appreciate any help you can provide.

  • You cannot test `D_score` on itself, run `print(cols)` to see that the last variable name is `D_score`. Try instead running the tests for the first 3 columns only `cols <- names(df1)[1:3]`. – Rui Barradas Jul 28 '23 at 05:28
  • Yes, that is right. Thanks, but how can I make a gtsummary table with mean±SD from this loop?? – Esraa Alfadul Jul 28 '23 at 06:04

0 Answers0