[R] Creating x*y different contigency tables

Loukia Spineli
Wed, 26 Sep 2012 07:59:19 -0000

Dear all,

I am trying to construct  25x31 different matrices of 2x2 dimension. Here
is the problem:

we have the following matrix
                                                       matrix(c(54+s0,
43+s1, 56-s0, 67-s1), nrow=2, ncol=2, byrow=T)

the values for s0 and s1 are c(0:24) and c(0:31), respectively.

I wrote the following code without the desired results

                                            x<-0:24
                                            y<-0:30

  results<-array(matrix(0,nrow=2,ncol=2,byrow=T),dim=c(2,2,25*31))
                                                   for(i in 1:25){
                                                        for(j in 1:31){
                                                             for(k in
1:25*31){

 results[,,k]<-array(matrix(c(54+x[i], 43+y[j], 56-x[i],
67-y[j]),nrow=2,ncol=2,byrow=T),dim=c(2,2,25*31))
                                                             }
                                                         }
                                                     }
                                                     results

I am trying to figure out what I am missing.

Thank you very much in advance for the help!

Loukia Maria

	[[alternative HTML version deleted]]