[R] pattern matching accross multiple matrices

2007-11-08 Thread Martin Tomko
Hi all, I have a set of patterns which can occur in a series of (3) matrices. I want to identify those and create a fourth one with the identifiers of the cases. Something like: for (i in 1:l) { for (j in 1:w) { A[A[i,j]==1 D[i,j]==1

[R] pattern matching accross multiple matrices

2007-11-08 Thread Martin Tomko
Hi all, I have a set of patterns which can occur in a series of (3) matrices. I want to identify those and create a fourth one with the identifiers of the cases. Something like: for (i in 1:l) { for (j in 1:w) { A[A[i,j]==1 D[i,j]==1

Re: [R] pattern matching accross multiple matrices

2007-11-08 Thread jim holtman
You are putting your results back into A which might change things as you execute. This might be a faster way: result - matrix(NA,dim(A)[1], dim(A)[2]) # now compute the cases result[(A ==1) (D == 1) (P ==1)] - Case1 result[(A == -1) (D == -1) (P == -1)] - Case2 ... On Nov 8, 2007