title: Using loop to create new variables
body: <p>My data frame is called <strong>Subs</strong>. </p>
  
  <p>My variables are <code>REV_4</code>, <code>REV_5</code>, <code>REV_6</code> etc </p>
  
  <p>I want to create new variables to calculate percentage change of revenue. <br/>
  Eg:  <code>d.rev.5 &lt;-  Subs$REV_5/Subs/$REV_4 -1</code> </p>
  
  <p>I would like to use a loop to create these new variables. I've tried this:</p>
  
  <pre><code>for(i in 5:10){
  Subs$d.data.[i] &lt;- Subs$REV_[i]/Subs$REV_[i-1] - 1 }
  </code></pre>
  
  <p>But it <strong>doesn't work</strong>. 
  I suspect it's not recognizing the <code>i</code> as part of the variable name. </p>
  
  <p>Is there any way to get around this?  Thank you so much. </p>