Iurie Malai
2009-Oct-23 17:45 UTC
[R] How to apply the Wilcoxon test to a hole table at once?
Hi, I have a data set:> DatasetX1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 1 user1 m 22 19 28 24 12 18 9 7 4 5 4 7 5 7 9 2 user2 f 25 19 23 18 18 15 6 8 6 6 7 10 7 7 7 3 user3 f 28 21 24 18 15 12 10 6 7 9 5 10 5 9 5 4 user4 f 26 19 26 21 12 18 6 6 5 1 3 8 6 5 6 5 user5 m 21 22 26 18 9 6 4 6 1 7 2 4 4 6 4 6 user6 m 24 8 25 12 18 12 7 8 4 1 4 6 7 5 6 ............................................................... 71 user71 m 18 4 10 6 3 6 9 5 10 8 4 5 6 5 5 I can apply the Wilcoxon test on each column one by one, but how to do this on the hole table at once?> wilcox.test(X3 ~ X2, alternative="two.sided", data=Dataset)Wilcoxon rank sum test with continuity correction data: X3 by X2 W = 439, p-value = 0.1291 alternative hypothesis: true location shift is not equal to 0>I researched on this, but I can't find a solution. I would really appreciate any help. P.S. Excuse my lack of terminology :). Iurie Malai Moldova Pedagogical State University -- View this message in context: http://www.nabble.com/How-to-apply-the-Wilcoxon-test-to-a-hole-table-at-once--tp26030572p26030572.html Sent from the R help mailing list archive at Nabble.com.
Steven McKinney
2009-Oct-24 04:04 UTC
[R] How to apply the Wilcoxon test to a hole table at once?
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Iurie Malai > Sent: Friday, October 23, 2009 10:46 AM > To: r-help at r-project.org > Subject: [R] How to apply the Wilcoxon test to a hole table at once? > > > Hi, > > I have a data set: > > > Dataset > X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 > 1 user1 m 22 19 28 24 12 18 9 7 4 5 4 7 5 7 9 > 2 user2 f 25 19 23 18 18 15 6 8 6 6 7 10 7 7 7 > 3 user3 f 28 21 24 18 15 12 10 6 7 9 5 10 5 9 5 > 4 user4 f 26 19 26 21 12 18 6 6 5 1 3 8 6 5 6 > 5 user5 m 21 22 26 18 9 6 4 6 1 7 2 4 4 6 4 > 6 user6 m 24 8 25 12 18 12 7 8 4 1 4 6 7 5 6 > ............................................................... > 71 user71 m 18 4 10 6 3 6 9 5 10 8 4 5 6 5 5 > > I can apply the Wilcoxon test on each column one by one, but how to do > this > on the hole table at once? > > > wilcox.test(X3 ~ X2, alternative="two.sided", data=Dataset) > > Wilcoxon rank sum test with continuity correction > > data: X3 by X2 > W = 439, p-value = 0.1291 > alternative hypothesis: true location shift is not equal to 0 > > >Here's one way to do it (using airquality dataset)> lapply(airquality[1:4], function(x) wilcox.test(x ~ Month, alternative="two.sided", data=airquality, subset = Month <= 6))$Ozone Wilcoxon rank sum test with continuity correction data: x by Month W = 82, p-value = 0.1925 alternative hypothesis: true location shift is not equal to 0 $Solar.R Wilcoxon rank sum test with continuity correction data: x by Month W = 391.5, p-value = 0.8354 alternative hypothesis: true location shift is not equal to 0 $Wind Wilcoxon rank sum test with continuity correction data: x by Month W = 566, p-value = 0.1461 alternative hypothesis: true location shift is not equal to 0 $Temp Wilcoxon rank sum test with continuity correction data: x by Month W = 78, p-value = 2.400e-08 alternative hypothesis: true location shift is not equal to 0 Warning messages: 1: In wilcox.test.default(x = c(41L, 36L, 12L, 18L, 28L, 23L, 19L, : cannot compute exact p-value with ties 2: In wilcox.test.default(x = c(190L, 118L, 149L, 313L, 299L, 99L, : cannot compute exact p-value with ties 3: In wilcox.test.default(x = c(7.4, 8, 12.6, 11.5, 14.3, 14.9, 8.6, : cannot compute exact p-value with ties 4: In wilcox.test.default(x = c(67L, 72L, 74L, 62L, 56L, 66L, 65L, : cannot compute exact p-value with ties # Sanity check:> wilcox.test(Temp ~ Month, alternative="two.sided", data=airquality, subset = Month <= 6)Wilcoxon rank sum test with continuity correction data: Temp by Month W = 78, p-value = 2.400e-08 alternative hypothesis: true location shift is not equal to 0 Warning message: In wilcox.test.default(x = c(67L, 72L, 74L, 62L, 56L, 66L, 65L, : cannot compute exact p-value with ties># Same as lapply loop result HTH Steven McKinney Statistician Molecular Oncology and Breast Cancer Program British Columbia Cancer Research Centre> > I researched on this, but I can't find a solution. > I would really appreciate any help. > > P.S. Excuse my lack of terminology :). > > Iurie Malai > Moldova Pedagogical State University > -- > View this message in context: http://www.nabble.com/How-to-apply-the- > Wilcoxon-test-to-a-hole-table-at-once--tp26030572p26030572.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Iurie Malai
2009-Oct-24 05:23 UTC
[R] How to apply the Wilcoxon test to a hole table at once?
Thank you! Here is my adapted script:>lapply(Dataset[3:17], function(x) wilcox.test(x ~ X2,alternative="two.sided", data=Dataset, subset = X2 <= 2)) but in R I have nothing, and in R Commander I have this error message: ERROR: grouping factor must have exactly 2 levels My grouping factor is in X2 column and there are only two levels (m and f). Where is the problem? Iu. Malai Iurie Malai wrote:> > Hi, > > I have a data set: > >> Dataset > X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 > 1 user1 m 22 19 28 24 12 18 9 7 4 5 4 7 5 7 9 > 2 user2 f 25 19 23 18 18 15 6 8 6 6 7 10 7 7 7 > 3 user3 f 28 21 24 18 15 12 10 6 7 9 5 10 5 9 5 > 4 user4 f 26 19 26 21 12 18 6 6 5 1 3 8 6 5 6 > 5 user5 m 21 22 26 18 9 6 4 6 1 7 2 4 4 6 4 > 6 user6 m 24 8 25 12 18 12 7 8 4 1 4 6 7 5 6 > ............................................................... > 71 user71 m 18 4 10 6 3 6 9 5 10 8 4 5 6 5 5 > > I can apply the Wilcoxon test on each column one by one, but how to do > this on the hole table at once? > >> wilcox.test(X3 ~ X2, alternative="two.sided", data=Dataset) > > Wilcoxon rank sum test with continuity correction > > data: X3 by X2 > W = 439, p-value = 0.1291 > alternative hypothesis: true location shift is not equal to 0 > >> > > I researched on this, but I can't find a solution. > I would really appreciate any help. > > P.S. Excuse my lack of terminology :). > > Iurie Malai > Moldova Pedagogical State University >-- View this message in context: http://www.nabble.com/How-to-apply-the-Wilcoxon-test-to-a-hole-table-at-once--tp26030572p26036261.html Sent from the R help mailing list archive at Nabble.com.
Uwe Ligges
2009-Oct-24 15:14 UTC
[R] How to apply the Wilcoxon test to a hole table at once?
Iurie Malai wrote:> Hi, > > I have a data set: > >> Dataset > X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 > 1 user1 m 22 19 28 24 12 18 9 7 4 5 4 7 5 7 9 > 2 user2 f 25 19 23 18 18 15 6 8 6 6 7 10 7 7 7 > 3 user3 f 28 21 24 18 15 12 10 6 7 9 5 10 5 9 5 > 4 user4 f 26 19 26 21 12 18 6 6 5 1 3 8 6 5 6 > 5 user5 m 21 22 26 18 9 6 4 6 1 7 2 4 4 6 4 > 6 user6 m 24 8 25 12 18 12 7 8 4 1 4 6 7 5 6 > ............................................................... > 71 user71 m 18 4 10 6 3 6 9 5 10 8 4 5 6 5 5 > > I can apply the Wilcoxon test on each column one by one, but how to do this > on the hole table at once?Whole table? Each variable against every other variable? Or something else? Do you think that makes sense? Anyway, you can calculate all combinations of 2 unique columns and iterate over them. Uwe Ligges>> wilcox.test(X3 ~ X2, alternative="two.sided", data=Dataset) > > Wilcoxon rank sum test with continuity correction > > data: X3 by X2 > W = 439, p-value = 0.1291 > alternative hypothesis: true location shift is not equal to 0 > > > I researched on this, but I can't find a solution. > I would really appreciate any help. > > P.S. Excuse my lack of terminology :). > > Iurie Malai > Moldova Pedagogical State University
Iurie Malai
2009-Oct-24 20:21 UTC
[R] How to apply the Wilcoxon test to a hole table at once?
Uwe Ligges-3 wrote:> > > Whole table? Each variable against every other variable? Or something > else? Do you think that makes sense? > Anyway, you can calculate all combinations of 2 unique columns and > iterate over them. > > Uwe Ligges >In the variable X2 I have encoded men and women, so I want to compare results of them for each variable by Wilcoxon rank-sum test. -- View this message in context: http://www.nabble.com/How-to-apply-the-Wilcoxon-test-to-a-hole-table-at-once--tp26030572p26042703.html Sent from the R help mailing list archive at Nabble.com.