> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of syrvn > Sent: Wednesday, January 11, 2012 2:36 AM > To: r-help@r-project.org > Subject: Re: [R] 2 sample wilcox.test != kruskal.test > > Hi, > > thanks for your answer. Unfortunately I cannot reproduce your results. > > In my example the results still differ when I use your approach: > > > x <- c(10,11,15,8,16,12,20) > > y <- c(10,14,18,25,28,30,35) > > f <- as.factor(c(rep("a",7), rep("b",7))) > > d <- c(x,y) > > kruskal.test(x,y) > > Kruskal-Wallis rank sum test > > data: x and y > Kruskal-Wallis chi-squared = 6, df = 6, p-value = 0.4232 > > > kruskal.test(x~y) > > Kruskal-Wallis rank sum test > > data: x by y > Kruskal-Wallis chi-squared = 6, df = 6, p-value = 0.4232 > > > kruskal.test(d~f) > > Kruskal-Wallis rank sum test > > data: d by f > Kruskal-Wallis chi-squared = 3.6816, df = 1, p-value = 0.05502 > > > kruskal.test(f~d) > > Kruskal-Wallis rank sum test > > data: f by d > Kruskal-Wallis chi-squared = 11.1429, df = 12, p-value = 0.5167 > > > I know the last kruskal.test(f~d) is not correct as the factor is always > placed as the second bit but I still tried it that way just to be sure... > > Cheers > >
You don't provide context, so I don't know what results you can't reproduce. But you need to reread the help page for the kruskal.test and look at the examples give. If x and y are the results for two independent groups, then the call to the kruskal.test should be either kruskal.test(list(x,y)) #or, kruskal.test(d~f) Hope this is helpful, Dan Daniel Nordlund Bothell, WA USA ______________________________________________ R-help@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.