On Tue, 2005-11-01 at 12:39 +0200, Erez wrote: > Hi > > I need an advise if any one can help me. > i have mass of data in 2 array A and B: > A = 0 1 0 0 1 1 0 0 > B = 0 0 0 1 0 1 1 1 > and i have 3 rules to merge them into 3rd array C: > if A[i] + B[i] == 0 then C[i]=0 > if A[i] + B[i] == 1 then C[i]=1 > if A[i] + B[i] == 2 then C[i]=2 > it looks easy but with the regular way (loop) with large data it takes days > (i test it). > If any one can advise me what to do i'll be happy. > > Thanks > Erez >
[I did not see a reply to this. The date indicates that it was sent on Tuesday, but I just got it today] Please use an informative subject. What's wrong with just adding the two vectors, if the rules are as simple as you indicate? > A [1] 0 1 0 0 1 1 0 0 > B [1] 0 0 0 1 0 1 1 1 > C <- A + B > C [1] 0 1 0 1 1 2 1 1 HTH, Marc Schwartz ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html