Re: [R] an efficient pairwise matrix cell's comparison function

2008-03-02 Thread Prof Brian Ripley
C <- B C[A==0] <- 0 would be somewhat more efficient. On Sun, 2 Mar 2008, jim holtman wrote: Does this do what you want? A <- matrix(sample(0:2, 25, TRUE), ncol=5) B <- matrix(1:25, ncol=5) C <- ifelse(A == 0, 0, B) A [,1] [,2] [,3] [,4] [,5] [1,]11121 [2,]10

Re: [R] an efficient pairwise matrix cell's comparison function

2008-03-02 Thread jim holtman
Does this do what you want? > A <- matrix(sample(0:2, 25, TRUE), ncol=5) > B <- matrix(1:25, ncol=5) > C <- ifelse(A == 0, 0, B) > A [,1] [,2] [,3] [,4] [,5] [1,]11121 [2,]10110 [3,]00102 [4,]01200 [5,]12

[R] an efficient pairwise matrix cell's comparison function

2008-03-02 Thread Diogo André Alagador
To all, I am undergoing an analysis involving big matrices of about 3x200 which I have to handle in a more efficient way. So I would like some advice to build such efficient function to deliver the following result: - starting with 2 matrices of the same dimension (eg. A and B)