[R] another matrix question

From: William Simpson <william.a.simpson_at_gmail.com>
Date: Mon, 21 Apr 2008 11:05:37 +0100


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



R-help_at_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 commented, minimal, self-contained, reproducible code. Received on Mon 21 Apr 2008 - 10:08:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 Apr 2008 - 22:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive