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 <chintanu at gmail.com>
To: R help <r-help at 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 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.