[R] Wilcoxon test output as a table

From: Iurie Malai <iurie.malai_at_gmail.com>
Date: Sun, 06 Jun 2010 00:18:15 +0300


I searched some time ago a way to get the Wilcoxon test results as a table more or less formatted. Nobody told me any solution and I found nothing on the Internet. Recently I came across this link ( http://myowelt.blogspot.com/2008/04/beautiful-correlation-tables-in-r.html), which helped me to find a solution.

Here's the solution (I'm using R Commander):

W <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac, alternative="two.sided", data=Dataset)$statistic)) P <- as.matrix(lapply(Dataset[2:11], function(x) wilcox.test(x ~ GrFac,

alternative="two.sided", data=Dataset)$p.value))
W <- format(W, digits = 5, nsmall = 2)
P <- format(P, digits = 1, nsmall = 3)

Wnew <- matrix(paste(W), ncol=ncol(Dataset[2:11])) colnames(Wnew) <- paste(colnames(Dataset[2:11])) Wnew

This is the output (excerpt):
> Wnew

     X1        X2        X3        X4        X5        X6        X7
X8        IA        IV

[1,] "4582.50" "4335.50" "4610.50" "4008.50" "6409.50" "6064.50" "5126.50" "6861.50" "4305.50" "5769.00"
> P

 [1] "0.301" "0.100" "0.336" "0.013" "5e-04" "0.008" "0.756" "4e-06" "0.089" "0.059"

Can anyone share their views? Propose an improvement? For example, how to make it appear as a table, not as separate rows? How to remove quotes? How to show rows names W and P?

Iurie Malai, Senior Lecturer
Department of Psychology
Faculty of Psychology and Special Education Ion Creanga Moldova Pedagogical State University - www.upsm.md http://en.wikipedia.org/wiki/Ion_Creang%C4%83_Pedagogical_State_University

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Received on Sat 05 Jun 2010 - 21:22:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 06 Jun 2010 - 04:40:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive