title: Get a result in the form of a matrix with mapply in R
body: <p>I use <code>mapply</code> with a function of mine on two matrices but the end result is a vector. I have tried using <code>SIMPLIFY = TRUE</code> with no success.</p>
  
  <p>Is there a way for me to get my results in the form of a matrix without having to structure ?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>&gt; a=matrix(c(0,2, 0, 0, 1, 3, 0, 3, 2, 0, 3, 5, 0, 4, 0, 0),ncol=4)
  &gt; a
   [,1] [,2] [,3] [,4]
  [1,]    0    1    2    0
  [2,]    2    3    0    4
  [3,]    0    0    3    0
  [4,]    0    3    5    0
  
  
  &gt; ab=matrix(c(4,2, 0, 7, 1, 4, 5, 3, 2, 6, 3, 7, 1, 2, 1, 2),ncol=4)
  &gt; ab
   [,1] [,2] [,3] [,4]
  [1,]    4    1    2    1
  [2,]    2    4    6    2
  [3,]    0    5    3    1
  [4,]    7    3    7    2
  &gt; mapply(l0.0025,a,ab)
   [1] 3.9900 0.0000 0.0000 6.9825 0.0000 0.9975 4.9875 0.0000 
   [9] 0.0000 5.9850 0.0000 1.9950 0.9975 0.0050 0.9975 1.9950
  l0.0025 &lt;- function(x, y) { 
        if (x-y &gt;= 0) {0.0025*(x-y)} else {-(1-0.0025)*(x-y)} 
  }
  </code></pre>