One statistical point beyond A.K.'s well done response. As you should well know, Kruskal-Wallis is a non-parametric equivalent of ANOVA. However, you only have two groups and do not require an ANOVA approach. You could simply use a Mann-Whitney U (aka.. independent Wilcoxon) test using wilcox.test().
Charles On Mon, Apr 15, 2013 at 8:23 AM, arun <smartpink...@yahoo.com> wrote: > Hi, > > set.seed(25) > myFile1<-as.data.frame(matrix(sample(1:40,50,replace=TRUE),nrow=10)) > row.names(myFile1)<- LETTERS[1:10] > groups <- rep (0:1, c(3,2)) > kruskal<-apply(myFile1,1,kruskal.test,groups) > p_kruskal <- sapply(kruskal, function(x) x$p.value) > p_kruskal > # A B C D E > F G > #0.08326452 0.08326452 0.56370286 0.56370286 0.24821308 1.00000000 > 0.08326452 > # H I J > #1.00000000 0.37425932 0.56370286 > #or > sapply(seq_len(nrow(myFile1)),function(i) > kruskal.test(unlist(myFile1[i,]),groups)$p.value) > [1] 0.08326452 0.08326452 0.56370286 0.56370286 0.24821308 1.00000000 > [7] 0.08326452 1.00000000 0.37425932 0.56370286 > A.K. > > ----- Original Message ----- > From: Chintanu <chint...@gmail.com> > To: R help <r-help@r-project.org> > Cc: > Sent: Monday, April 15, 2013 1:18 AM > Subject: [R] Kruskal-Wallis > > Hi, > > I have got two groups of samples; and for every row, I wish to calculate > Kruskal-Wallis' p-value. > In the example below, and the stars (****) show where I am struggling to > design and put things together. Any help would be appreciated. > > > myFile <- data.frame(Sample_1a = 1:10, Sample_1b = 2:11, Sample_1c = 3:12, > Sample_2a=4:13, Sample_2b=7:16, row.names=LETTERS[1:10]) > > groups <- rep (0:1, c(3,2)) > > kruskal <- apply(myFile [1:nrow(myFile),], 1, kruskal.test, ******) > > p_kruskal <- sapply(kruskal, function(x) x$p.value) > > Thanks, > Chintanu > > [[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. > > > ______________________________________________ > 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. > -- Charles Determan Integrated Biosciences PhD Student University of Minnesota [[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.