title: How to iterate growth based on daily growth rate for multiple columns using a for loop
body: <p>I have a df with growth rates per species A, B, and C for about 60 days. df1 is an example.</p>
  <pre><code>df1 &lt;- data.frame(Day = c('59','60' ), A= c('.1', '.6'), B= c('.2', '.5'), C=c('.3','.4'))
  </code></pre>
  <p>df1=Growthrates</p>
  <p>I am calculating the cell count for each day based on a given initial cell count (1000).
  I want a df that uses the initial cell count and the corresponding daily growth rate for each species from df1
  such that the calculated cell count under each column (A,B,or C) in df2 is calculated with the cell count from the previous day and the rate from &quot;today&quot;.</p>
  <p>Using the example above, I could start with my second df (df2) on day 58 (rather than 59 like in df1) and calculate each value thereafter.</p>
  <pre><code>df2 &lt;- data.frame(Day = c('58','59','60' ), A= c('1000', '1100', '1760'), B= c('1000','1200', '18000'), C=c('1000','1300','1820'))
  </code></pre>
  <p>df2=calculated cell counts (with initial input as 1000). The remaining provided values are what would be expected if the calculation is successful.</p>
  <p>The simple equation is as follows for any particular species:</p>
  <p><strong>Day59 Cell count= Cell count(day 58)*( 1+growth rate (day 59))</strong></p>
  <p>After the initial cell count, it will need to use the newly generated value as input for the next calculation</p>
  <p><strong>Cell count (day 60)= Cell count (day 59)*( 1+growth rate (day 60))</strong></p>
  <p>I am having trouble converting this to a for loop where. Any help is much appreciated.</p>
  <p>Thank you in advance.</p>