0

I've been doing Dunns tests as post-hoc and corrections for my thesis data and I've run into an issue. I have 67 variables and 3 groupings that I'm running through, so loops just easily solve the tons of data analysis.

ind1 var1(6) var... var67(73)
a value value value
b value value value
c value value value

I've done a normal kruskal.test for all my variables and groups with no issue, but "dunnTest" and dunn_test" both stop at 27 variables

library(FSA)

Dunn_df = list()
for(i in names(df[,6:73])){  
  Dunn_df[[i]] <- dunnTest(formula(paste(i, "~ ind1")), data = df, method = "bonferroni")
  
}

and

library(rstatix)  

Dunn_df = list()
for(i in names(df[,6:73])){  
  Dunn_df[[i]] <- dunn_test(formula(paste(i, "~ ind1")), data = df, p.adjust.method="BH")
  
}

both output a nested list that I've able to read with print(Dunn_df), but only do the dunn test on columns 6:32.

mcChris
  • 23
  • 4
  • 1
    If it runs fine for a while and then gets hung on a specific part of the data it suggests there's an issue in that specific part of the data. Could you check for `NA` values in your data? `dunnTest()` has an `na.action` argument that might help. – Dan Adams Nov 21 '22 at 20:49

1 Answers1

0

Without any reproducible example it is very difficult to help you. Using the example data mtcars, the function works just fine on a large number of variables, e.g.

library(rstatix)
library(purrr)
rep(colnames(mtcars),10)  |> 
  purrr::map(
  ~dunn_test(formula(paste(.x, "~mpg")), data = mtcars, p.adjust.method="BH")
  )
Julian
  • 6,586
  • 2
  • 9
  • 33