Re: [R] another matrix question

2008-04-21 Thread William Simpson
Thanks Julien & Rolf for your help. The double commas were just typos. Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commen

Re: [R] another matrix question

2008-04-21 Thread Rolf Turner
On 21/04/2008, at 10:05 PM, William Simpson wrote: > 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]=

Re: [R] another matrix question

2008-04-21 Thread Julien Barnier
Hi, > 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. m <- matrix(c(0,1,2,3,4,0,5,6,0),nrow=3,ncol=3) n <- mat

[R] another matrix question

2008-04-21 Thread William Simpson
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 a