title: Producing equal results for column entries which are the same
body: <p>I have the piece of code below. What i want is alter the code
  such that when the column entries for mat are the same, i get the same result in their respective positions in summation without it performing the fit operation?</p>
  <p>So instead of getting</p>
  <pre><code>             1    3    5    1    7    1
               2    4    6    2    8    2  
               3    9   12    5   16    4  
  </code></pre>
  <p>I want</p>
  <pre><code>           1    3    5    1    7    1
             2    4    6    2    8    2
             3    9   12    3   16    3
  </code></pre>
  <pre><code>   set.seed(123)
     fit = function(A){
         x = A[1]
         y = A[2]
         z = sum(sample((x+y),2))
         return(z)
    }
    mat= matrix(c(1,2,3,4,5,6,1,2,7,8,1,2),nrow=2,ncol=6)
    summation=apply(mat, 2, FUN = 'fit')
    newmat=rbind(mat,summation)
    newmat 
  
  </code></pre>