R: ggplot2 - Kruskal-Wallis test per facet
问题 I have boxplots in multiple facets and I would like to perform a Kruskal-Wallis test on each facet, and place the result on top-left of each respective facet. To exemplify this, I am using the iris dataset, to which I added an additional variable named "treatment". MWE: library(reshape2) library(ggplot2) data(iris) iris$treatment <- rep(c("A","B"), length(iris$Species)/2) mydf <- melt(iris, measure.vars=names(iris)[1:4]) mydf$treatment <- as.factor(mydf$treatment) mydf$variable <- factor(mydf