title: Proportional adjustment method in R
body: <p>I have one table with four columns Y, T, D, AF.So my intention is to apply so called "<em>proportional adjustment method</em>".</p>
  
  <pre><code>library(dplyr)
  
  df&lt;-data.frame(
  Y=c(2017,2016,2015,2014,2013,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000),
  T=c(11742,10927,9931,9477,7888,7348,7318,6825,6700,6688,6841,6472,6228,5928,5771,5780,5575,8302),
  D=c(0,450,0,1540,0,0,0,-314,0,-1200,0,0,0,0,0,0,-3707,0),
  AF=c(  1.000, 1.043 , 1.000 , 1.194 , 1.000 , 1.000 , 1.000 , 0.956 , 1.000 , 0.848 , 1.000 , 1.000 , 1.000 , 1.000 , 1.000 , 1.000 ,0.601 , 1.000 ))
  </code></pre>
  
  <p>In order to apply proportional adjustment method on this table I should apply formulas like screen shoot from Excel below.</p>
  
  <p><a href="https://i.stack.imgur.com/toCG9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/toCG9.jpg" alt="enter image description here"></a></p>
  
  <p>For that reasons I am trying to resolve this issue with, cumproduct function and dplyr package with this code:</p>
  
  <pre><code>df1&lt;-mutate(df,
                AT=  T*lag(cumprod(AF), k=1, default=1)
                )
  
    View(df1)
  </code></pre>
  
  <p>But I got results in <strong>AT column</strong>, which very similar with correct results but is not the same.So can anybody help me with this code how to apply formula like screen shoot from Excel, with some function or whatever?</p>
  
  <p><a href="https://i.stack.imgur.com/mPeKu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mPeKu.jpg" alt="enter image description here"></a></p>