title: Calculating division of unique pairs for each row in a matrix
body: <p>Here I have a 5*4 matrix (much larger originally). I would like to calculate the ratios for each unique pair in each row of a matrix.</p>
  
  <pre><code>X1  X2  X3  X4
  10  8   2   1
  4   4   3   6
  2   10  8   1
  1   2   1   10
  3   5   5   4
  </code></pre>
  
  <p>I would like to achieve a 5*6 matrix with non repeating divisions, like the following ></p>
  
  <pre><code>x1/x2   x1/x3   x1/x4   x2/x3   x2x4    x3/x4
  1.25    5.00    10.00   4.00    8.00    2.00
  1.00    1.33    0.67    1.33    0.67    0.50
  0.20    0.25    2.00    1.25    10.00   8.00
  0.50    1.00    0.10    2.00    0.20    0.10
  0.60    0.60    0.75    1.00    1.25    1.25
  </code></pre>
  
  <p>For now I have created a functions that I hoped would do the trick, however the outcome is not as expected.</p>
  
  <pre><code>set.seed(7)
  test &lt;- data.frame(replicate(4,sample(1:10,5,rep=TRUE)))
  
  func_calcRatio &lt;- function(theMatrix){
  
    ratios &lt;- outer(theMatrix, theMatrix, '/')
    ratios &lt;- ratios[upper.tri(ratios)]
    return(ratios)
  }
  
  
  func_ratioMatrix &lt;- function(theMatrix){
  
    ratios_list &lt;- list()
    i = 1
    l = length(theMatrix)
    for (i in 1:l) {
      vec &lt;- numeric(l)
      for (j in 1:l){
        vec[j] &lt;- i^j
      }
      myrow &lt;- theMatrix[,1]
      onerow &lt;- func_calcRatio(myrow)
      ratios_list[[i]] &lt;- onerow
      i = i+1
    }
  
    ratios_df &lt;- do.call("rbind", ratios_list)
    return(ratios_df)
  }
  
  test.ratios &lt;-  func_ratioMatrix(test)
  </code></pre>