[R] Wilcoxon Rank Sum in R with a multiple testing correction

Mark Difford mark_difford at yahoo.co.uk
Wed Nov 24 09:27:23 CET 2010

Hi Selthy,

>> I'd like to use a Wilcoxon Rank Sum test to compare two populations of
>> values. Further, I'd like 
>> to do this simultaneously for 114 sets of values.

Well, you read your data set into R using:


There are other ways to bring in data. Save the import to a workspace object
at the same time:

myDat <- read.csv (...)

Do the Wilcoxon Rank Sum tests using the implementation of your choice
(there are several):

## See the examples at foot of help page. Lacking data we will make some.

pv1 <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)$p.value
pv2 <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)$p.value
pv3 <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)$p.value

Eventually you will discover more elegant ways of assembling a vector (or
some other type of storage object).

Finally, you feed your p-values to:

pAdj <- p.adjust (c(pv1, pv2, pv3), method = c("BH"))

cbind.data.frame (Uncorrected = c(pv1, pv2, pv3), BH_Corrected = pAdj)

Eventually you will discover how to turn all of this into an elegant
function. I really do hope that this is not a school assignment. If so....
Well, you still need to do some work to get this going.

Regards, Mark.
View this message in context: http://r.789695.n4.nabble.com/Wilcoxon-Rank-Sum-in-R-with-a-multiple-testing-correction-tp3056557p3056878.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list