title: Dividing all values by the last entry of their row in R studio
body: <p>I am working in R studio and I have a dataset such as:
  (the letters stand for the column names)</p>
  
  <pre><code> a b c d e f 
   0 1 3 1 0 1 
   3 1 0 4 1 2
   0 1 0 0 3 4
  </code></pre>
  
  <p>I want to divide all values by the f-value corresponding to their column. So that would mean every value in the first row has to be divided by 1, every value in the second row by two and every value in the third row by 4.</p>
  
  <p>i ve tried it like this:</p>
  
  <pre><code>#divide every number through sum variable of their row
  my_matched_matrix = as.matrix(my_matched)
  
  #making a vector out of sum row
  avector &lt;- as.vector(my_matched['sum'])
  
  #sweep
  sweeped &lt;- sweep(mat,avector, `/`)
  </code></pre>
  
  <p>it gives me this error:</p>
  
  <pre><code>Error in dims[MARGIN] : invalid subscript type 'list'
  </code></pre>
  
  <p>Does anyone have an idea if there is any other way of getting where i want?</p>