After a long struggle with this problem, I hope to get some tips here. I am wondering if anyone knows of an automated method for determining paired grouping labels by value. The question does not depend on the significance test (for example, Tukey for parametric or Mann-Whitney for non-parametric) - in these pairwise comparisons, some figures of the boxplot type often represent these groups with a sub script:

, . , - , , , , , , 2 , 3 .., , .
, 1 3 5, 3 5 (.. ).
:
set.seed(1)
n <- 7
n2 <- 100
mu <- cumsum(runif(n, min=-3, max=3))
sigma <- runif(n, min=1, max=3)
dat <- vector(mode="list", n)
for(i in seq(dat)){
dat[[i]] <- rnorm(n2, mean=mu[i], sd=sigma[i])
}
df <- data.frame(group=as.factor(rep(seq(n), each=n2)), y=unlist(dat))
bp <- boxplot(y ~ group, df, notch=TRUE)
kr <- kruskal.test(y ~ group, df)
kr
mw <- pairwise.wilcox.test(df$y, df$g)
mw
mw$p.value > 0.05
text(x=1:n, y=bp$stats[4,], labels=c("AB", "C", "A", "D", "B", "D", "E"), col=1, cex=1.5, pos=3, font=2)