Question

I'm analyzing a dataset of 9 plots in R and want to compare them with each other. My responding variables are not normally distributed.

Now my question:

There are 9+8+7+...+2+1=45 pair-combinations to be tested. Can R do this automatically? If yes, how? My wish-output would be a box-whisker plot with my 9 plots on the x-axis, the responding variable on the y-axis and lowercase letters above the plots to indicate significant differences.

Thanks in advance!

Was it helpful?

Solution

This should get you started:

#some data
x <- rlnorm(100, mean=1:4)
DF <- data.frame(x=x, g=c("a", "b", "c", "d"), stringsAsFactors=FALSE)

#pairwise Mann-Whitney-U-test
pairwise.wilcox.test(DF$x, DF$g, p.adjust.method = "bonferroni")

#   Pairwise comparisons using Wilcoxon rank sum test 
#
#data:  DF$x and DF$g 
#
#  a       b       c     
#b 0.0016  -       -     
#c 6.3e-09 0.0020  -     
#d 1.9e-13 2.0e-08 0.1823
#
#P value adjustment method: bonferroni 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top