Scott:

Your problem specification is rather vague: What do you mean by "use"?

In general, matrices are merely vectors with a dim attribute, so if
you can do what you want with them as vectors, then that will work for
them as matrices. For example:

> m1<- matrix(1:6, nr=3)
> m2 <- matrix(11:16, nr=2)
> m2*m2
     [,1] [,2] [,3]
[1,]  121  169  225
[2,]  144  196  256

If this does not meet your needs, you will have to follow the posting
guide and provide both code and a minimal reproducible example.

Cheers,
Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Wed, Apr 30, 2014 at 10:54 AM, Waichler, Scott R
<scott.waich...@pnnl.gov> wrote:
> Hi,
>
> I want to apply a custom function to all the elements of one matrix.  The 
> function uses the value in the same i,j in a second matrix.  How can I use 
> apply() or similar function to avoid nested loops in i and j?
>
> Thanks,
> Scott Waichler
> Pacific Northwest National Laboratory
> Richland, WA, USA
>
> ______________________________________________
> 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 commented, minimal, self-contained, reproducible code.

______________________________________________
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 commented, minimal, self-contained, reproducible code.

Reply via email to