This code is working but it uses Fisher LSD test or I need compact letter display for kruskal-wallis Dunn post hoc test. Does anyone have a solution ?
library(agricolae)
kruskal_cld <- kruskal(MR$hauteur, MR$distance, group=TRUE, p.adj="bonferroni")$groups
kruskal_cld
cld <- as.data.frame(kruskal_cld)
cld$ordre <- c(6,3,1,2,4,5)
cld <- cld[order(cld$ordre), ]
ggplot(data=MR, aes(x=distance, y=hauteur,col=distance))+
scale_color_brewer(palette = "Dark2")+
scale_alpha(0.5)+
geom_jitter(position = position_jitterdodge(jitter.width = 1), size = 0.5)+
stat_summary(fun.data=mean_sd, size=0.4, col="black")+
geom_text(data = cld, aes(label = cld$groups, y = 50, x = ordre), vjust = -0.5, inherit.aes = FALSE)
I tried this code (find it on stackoverflow) but then I realise agricolae package do not use Dunn test but Fisher LSD to display the letters. I need to do it with the Dunn test for my analyze.
If it is fine for you to switch to another package capable of performing the dunnTest function, then the
FSApackage is one solution. Then, using thercompanionpackage you can get the compact letter display of your comparisons. As I do not have access to yourMRdata, I used themtcarsdata fromRto show how to do it in this way:# running kruskal-wallis test if there is any difference between groups
# running post hoc Dunn test
# Compact letter display of comparisons
# visualization of comparisons using ggplot (you need to adjust the plot arguments based on your dataset)