title: Conditionally sum a range of columns based on another column in R
body: <p>I've looked through several other related questions but haven't really found something that meets my case.</p>
  
  <p>I have a column that dictates how many columns will be summed into a new column.</p>
  
  <ul>
  <li>If <code>DEPENDENCY == INDEP</code> then <code>NET_AGI = IND_AGI</code></li>
  <li>If <code>DEPENDENCY == DEP</code> then <code>NET_AGI = PRO_AGI + IND_AGI</code></li>
  <li>Otherwise <code>NET_AGI = PRO_AGI</code></li>
  </ul>
  
  <pre><code>DEPENDENCY IND_AGI PRO_AGI  NET_AGI &lt;- NET_AGI will be the summed column
  INDEP      0049995    -     0049995
  DEP        0000500 0090500  0091000
  DEP        0009000 0121095  0130950
  DEP           -    0375001  0375001
  INDEP      0123456    -     0123456
  DEP        0012070 1023030  1035100
  ...
  </code></pre>
  
  <p>What's the best way to do that?</p>