title: How to calculate percentage from a table on R
body: <p><strong><a href="https://i.stack.imgur.com/iCLj6.png" rel="nofollow noreferrer">Hello,</a></strong> </p>
  
  <p>I have a table with 14 observations and 16 variables. (S0 to  S11 and the sum of the row at the end) 
  I would like to calculate the percentage of each value on the total (last column). 
  I tried prop.table but it's not giving me the right percentages. I also tried apply but same pb. </p>
  
  <p>Here is a sample of my table : </p>
  
  <pre><code>Row.name    S0  S1  S2  S3  S4  S5  Total
       S0     25987   269 9152    6042    30  32  41512
       S1     234 5575    768 4398    3321    34  14330
       S2     345546  35  79  245 21685   676 368266
       S3     5678    6   78  987 4657    789 12195
       S4     9   45  879 34  5768    246 6981
       S5     54  3   788 863 56  279826  281590
       S6     367 57678   12  842 436 5824    65159 
  
  The code I've tried : 
  
  prop.table(df)
  
  prop &lt;- apply(df, 1, function(x) x/ df$Total*100)
  </code></pre>
  
  <p>For the first line for example I would like to have 
  (25987/41512)*100    (269/41512)*100    (269/41512)*100 etc </p>
  
  <p>Thank you for ur help.</p>