title: R sum in a for loop
body: <p>I will try to put it in this way:</p>
  
  <p>I'm making a sum :</p>
  
  <pre><code>tot &lt;- fac$a[,1]+fac$b[,1]
  </code></pre>
  
  <p>Where a and b are factors and 1 the first column. And until here it's fine.</p>
  
  <p>Now I would like to use  a for loop in order to do the sum for the all columns:</p>
  
  <pre><code>tot &lt;- 0 
  for (i in 5:13) {
  tot[,i] &lt;- fac$a[,i]+fac$b[,i] 
  }
  </code></pre>
  
  <p>Which is not working.</p>
  
  <p>Any suggestion?
  Thanks.</p>