Re: [R] zeros to NA's - faster

2011-11-23 Thread Dennis Murphy
Matrix multiplication, maybe? > all_data %*% iu a b c [1,] 1 4 0 [2,] 2 5 0 [3,] 3 6 0 I have no idea if this is a general solution or not, but it works in this case. If you need something else, perhaps a more realistic example would help. Dennis On Wed, Nov 23, 2011 at 11:41 AM, Ben quant

Re: [R] zeros to NA's - faster

2011-11-23 Thread Jorge I Velez
Hi Ben, Try all_data[, colSums(iu) == 0] <- NA all_data HTH, Jorge.- On Wed, Nov 23, 2011 at 2:41 PM, Ben quant <> wrote: > Hello, > > Is there a faster way to do this? Basically, I'd like to NA all values in > all_data if there are no 1's in the same column of the other matrix, iu. > Put ano

[R] zeros to NA's - faster

2011-11-23 Thread Ben quant
Hello, Is there a faster way to do this? Basically, I'd like to NA all values in all_data if there are no 1's in the same column of the other matrix, iu. Put another way, I want to replace values in the all_data columns if values in the same column in iu are all 0. This is pretty slow for me, but