[R] another matrix question

William Simpson william.a.simpson at gmail.com
Mon Apr 21 12:05:37 CEST 2008

Hi everyone,

I would like to do the following.

Given matrix m and matrix n, I would like to compute mn[i,,j]= m[i,,j]
+ n[i,,j] if either of these elements is 0. (In other words, whichever
number is nonzero.)
Else I want mn[i,,j]=(m[i,,j] + n[i,,j])/2
I need a fast method.

Thanks very much for any help.

Bill Simpson

More information about the R-help mailing list