The devil is in the details (and in the arguments in Lukasz code). The defaults for the two functions are different: wilcox.test uses an exact test (which is not available in kruskal.test afaik) for your data, and uses the continuity correction if the normal approximation is requested (neither available in kruskal.test). See the manual (in particular ?wilcox.test) for details, or the pertinent literature for the theoretical background.
HTH, Michael > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Lukasz Reclawowicz > Sent: Wednesday, January 11, 2012 12:00 > To: syrvn > Cc: r-help@r-project.org > Subject: Re: [R] 2 sample wilcox.test != kruskal.test > > 2012/1/11 syrvn <ment...@gmx.net> > > > 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) > > > > Try to compare wilcox.test and right formula in kruskal, I got: > > all.equal(wilcox.test(x,y, correct = > F,exact=F)$p.value,kruskal.test(d~f)$p.value) > [1] TRUE > > -- > Mi³ego dnia > > [[alternative HTML version deleted]] ______________________________________________ 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.