[R] chisq.test

arun smartpink111 at yahoo.com
Tue Mar 5 15:47:44 CET 2013


If you wanted to do a t.test
res1<-do.call(cbind,lapply(seq_len(nrow(m)),function(i) do.call(rbind,lapply(split(rbind(m[i,-1],n),1:nrow(rbind(m[i,-1],n))), function(x) {x1<- rbind(x,m[i,-1]); t.test(x1[1,],x1[2,])$p.value}))))
 res2<-do.call(cbind,lapply(seq_len(ncol(res1)),function(i) c(c(tail(res1[seq(1,i,1),i],-1),1),res1[-c(1:i),i])))
 attr(res2,"dimnames")<-NULL
 res2
#          [,1]      [,2]      [,3]      [,4]
#[1,] 1.0000000 1.0000000 1.0000000 0.6027881
#[2,] 1.0000000 1.0000000 1.0000000 0.5790103
#[3,] 1.0000000 1.0000000 1.0000000 1.0000000
#[4,] 0.6027881 0.6027881 0.5637881 1.0000000

#here, the first column is testing a2, against a2, a,c,t, second c2, against t, c2, a,c, third c3 against c,t,c3,a, and fourth t2 against a,c,t, and t2.
A.K.






________________________________
From: Vera Costa <veracosta.rt at gmail.com>
To: arun <smartpink111 at yahoo.com> 
Sent: Tuesday, March 5, 2013 9:38 AM
Subject: Re: chisq.test


ok, thank you.

I will test. Thank you very much



>>________________________________
>>From: Vera Costa <veracosta.rt at gmail.com>
>>To: arun <smartpink111 at yahoo.com>
>>Sent: Tuesday, March 5, 2013 8:23 AM
>>Subject: Re: chisq.test
>>
>>
>>
>>Sorry if my explanation isn't good...
>>
>>I have this tables:
>>
>>m<-structure(list(id = structure(1:4, .Label = c("a2", "c2", "c3", 
>>"t2"), class = "factor"), `1` = c(0L, 0L, 0L, 1L), `2` = c(8L, 
>>8L, 6L, 10L), `3` = c(2L, 2L, 4L, 5L)), .Names = c("id", "1", 
>>"2", "3"), row.names = c("a2", "c2", "c3", "t2"), class = "data.frame")
>>
>>
>>n<-structure(c(0, 0, 1, 8, 7, 10, 2, 3, 5), .Dim = c(3L, 3L), .Dimnames = list(
>>    c("a", "c", "t"), c("1", "2", "3")))
>>
>>and I need to apply a chisq.test between all. I need to compare a2 to a,c an t. After compare c2 with a,c,and t.After c3 with a,c,and t.... 
>>
>>And the output will be some like this:
>>
>>             a             b             c
>>a2      xxx       xxxx            xxx
>>c2      xxx       xxxx            xxx
>>c3       xxx       xxxx            xxx
>>t2       xxx       xxxx            xxx
>>
>>where xxxx is the p-values.
>>
>>
>>It isn't possible?
>>
>>Vera
>>
>>
>>



More information about the R-help mailing list