title: summing rows of specific columns then dividing by the sum
body: <p>I am simply trying to sum certain columns in a row and then divide the cells within the row by that sum. And I am wanting to do this in every row. for example, if we take the data set:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>lose</th>
  <th>draw</th>
  <th>win</th>
  <th>goals</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>7</td>
  <td>2</td>
  <td>5</td>
  <td>12</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>13</td>
  <td>21</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>We will ignore the goals scored and sum the win, lose and draw columns for the row, then by dividing each cell by the sum value we obtain:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>lose</th>
  <th>draw</th>
  <th>win</th>
  <th>goals</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>7/14</td>
  <td>2/14</td>
  <td>5/14</td>
  <td>12</td>
  </tr>
  <tr>
  <td>1/16</td>
  <td>2 /16</td>
  <td>13/16</td>
  <td>21</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The code I have tried using is:</p>
  <pre><code>Df_new &lt;-t(apply(Df, select = c(lose, draw, win), function(x) x/sum(x)))
  </code></pre>
  <p>However, I am getting the error:</p>
  <p><strong>Error in match.fun(FUN) : argument &quot;FUN&quot; is missing, with no default</strong></p>
  <p>which a google search says I am missing a margin. But I thought that I had specified this by electing the columns.</p>
  <p>Thank you</p>