Re: [R] matrices call a function element-wise

2011-01-03 Thread Dennis Murphy
Hi: The idea is as follows: * string your four matrices into vectors, cbinding them so that the columns correspond to what you want as the (1,1), (1, 2), (2, 1) and (2, 2) elements, respectively, of the matrix/table to be used for the Fisher test; * Operate row-wise on the constructed matr

Re: [R] matrices call a function element-wise

2011-01-03 Thread Jonathan Christensen
Hi, I would recommend reformatting the data as a 2x2x1000 array and using apply. Jonathan On Mon, Jan 3, 2011 at 7:57 AM, zhaoxing731 wrote: > Hello > > I have 4 1000*1000 matrix A,B,C,D. I want to use the corresponding element of > the 4 matrices. Using the "for loop" as follow: > > E<-o > f

Re: [R] matrices call a function element-wise

2011-01-03 Thread Jonathan P Daily
org wrote on 01/03/2011 09:57:14 AM: > [image removed] > > [R] matrices call a function element-wise > > zhaoxing731 > > to: > > R-help > > 01/03/2011 01:46 PM > > Sent by: > > r-help-boun...@r-project.org > > Hello > > I have 4 100

[R] matrices call a function element-wise

2011-01-03 Thread zhaoxing731
Hello I have 4 1000*1000 matrix A,B,C,D. I want to use the corresponding element of the 4 matrices. Using the "for loop" as follow: E<-o for (i in 1:1000) {for (j in 1:1000) { E<-fisher.test(matrix(c(A[i][j],B[i][j],C[i][j],D[i][j]),2))#call fisher.test for every element } }