title: Using the result of a previous cell to compute the value in the current cell for the same variable in r
body: <p>I am working with a customer database. I would like to compute the value of a cell in a column called EAD1 by using the computed value of previous cell for the same EAD1 column.</p>
  <p>An example below shows the data and expected result for EAD1 for data set called data1</p>
  <pre><code>Acc_Num, Record_count, BRD, Account_Balance, EAD1  
  100, 1, 0.9, 100, 100
  100, 2, 0.9, 100,  90  
  100, 3, 0.9, 100,  81  
  102, 1, 0.8, 100, 100  
  102, 2, 0.8, 100,  80   
  
  For Record_count = 1, EAD1 = Account_Balance  
  For Record_count &gt; 1, EAD1 = EAD1 previous cell * BRD
  </code></pre>