[R] Wilcoxon test output as a table

Joris Meys jorismeys at gmail.com
Sat Jun 5 23:28:42 CEST 2010


# not tested
out <- rbind(as.numeric(Wnew),as.numeric(P))
rownames(out) <- c("Wnew","P")

Cheers

On Sat, Jun 5, 2010 at 11:18 PM, Iurie Malai <iurie.malai at gmail.com> wrote:
> Hi!
>
> 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
> P
>
> 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?
>
> Regards,
> 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.
>
>



-- 
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php



More information about the R-help mailing list