Re: [R] Conditional Operation in Matrix

2010-11-24 Thread Ivan Calandra
Hi, Would that work for you? d <- a-b d[a==0 | b==0] <- 0 The output is as the one expected HTH, Ivan Le 11/24/2010 15:54, Romildo Martins a écrit : Hello, I would like to perform the operation a - b, only for the non-zero values. Thanks a lot! RMB a 0 0 0 0 4 0 0 0 0 0 0 0

[R] Conditional Operation in Matrix

2010-11-24 Thread Romildo Martins
Hello, I would like to perform the operation a - b, only for the non-zero values. Thanks a lot! RMB > a 0 0 0 0 4 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > b