Hi, Please dput() your example dataset. dat1<- read.table(text="a?? a?? a?? a??? a??? b?? b??? b??? c??? c?? c??? c 2? 4??? 5?? 2??? 7??? 2?? 2??? 6??? 3??? 7?? 9??? 3 3? 3?? 4?? 1???? 6??? 8?? 1??? 3??? 5??? 2??? 6??? 3",sep="",header=FALSE,stringsAsFactors=FALSE) library(reshape) ?dat2<-melt(as.data.frame(t(dat1)),id.var="V1")[,-2] kruskal.test(value~V1,data=dat2) # #??? Kruskal-Wallis rank sum test # #data:? value by V1 #Kruskal-Wallis chi-squared = 1.2888, df = 2, p-value = 0.525 #I guess you wanted for each row: lapply(split(dat2,(seq_len(nrow(dat2))-1)%/%ncol(dat1)+1),function(x) kruskal.test(value~V1,data=x)) #$`1` # #??? Kruskal-Wallis rank sum test # #data:? value by V1 #Kruskal-Wallis chi-squared = 2.003, df = 2, p-value = 0.3673 # #$`2` #??? Kruskal-Wallis rank sum test #data:? value by V1 #Kruskal-Wallis chi-squared = 0.1231, df = 2, p-value = 0.9403 A.K. ________________________________ From: Vera Costa <veracosta.rt at gmail.com> To: arun <smartpink111 at yahoo.com> Sent: Wednesday, July 10, 2013 6:38 AM Subject: Re: Kruskal.test Thank you. And if I have a ? a ? a ? a ? ?a ? ?b ? b ? ?b ? ?c ? ?c ? c ? ?c 2 ?4 ? ?5 ? 2 ? ?7 ? ?2 ? 2 ? ?6 ? ?3 ? ?7 ? 9 ? ?3 3??3?? 4?? 1???? 6??? 8???1??? 3??? 5??? 2??? 6??? 3?? ? How can I apply the test by row? Thank you
Hi,
You could try:
Chisq1<-do.call(cbind,lapply(c(0.05,0.001),function(i)
{x1<-sapply(seq_len(nrow(Specc)),function(i)
chisq.test(as.table(unlist(Specc[i,-c(1:3)])))$p.value); sum(x1<i)}))
?Wilcox1<-do.call(cbind,lapply(c(0.05,0.001),function(i){x1<-sapply(seq_len(nrow(Specc)),function(i)
wilcox.test(unlist(Specc[i,-c(1:3)]))$p.value);sum(x1<i)}))
res<-rbind(Wilcox1,Chisq1)
?colnames(res)<- c("number of rows iwth p-value<0.05",
"number of rows with p-value<0.001")
?rownames(res)<-c("wilcox.test","chisq.test")
? res
#??????????? number of rows iwth p-value<0.05 number of rows with
p-value<0.001
#wilcox.test?????????????????????????????? 14???????????????????????????????? 0
#chisq.test???????????????????????????????? 0???????????????????????????????? 0
#The warnings() were there for all the rows.
#If you want, you could have a new column with "name of test", instead
of rownames.
A.K.
________________________________
From: Vera Costa <veracosta.rt at gmail.com>
To: arun <smartpink111 at yahoo.com>
Sent: Friday, July 19, 2013 1:25 PM
Subject: Re: Kruskal.test
Thank you.
But I need to construct a dataframe like I sent you. You can help me in this? I
will look for your code in a few moments
No dia 19 de Jul de 2013 18:20, "arun" <smartpink111 at
yahoo.com> escreveu:
Seemingly Similar Threads
- Kruskal.test
- Kruskal.test() on lists
- Saving kruskal wallis p-values
- Equivalence of Mann-Whitney test and Kruskal-Wallis test with k=2
- Multiple Comparisons-Kruskal-Wallis-Test: kruskal{agricolae} and kruskalmc{pgirmess} don't yield the same results although they should do (?)