title: How to write a function where the coefficient tends to 0 in R?
body: <p>I would like to write a function that smooths the coefficient of growth rate to 0 in 60 days. So far I managed to write the following code:</p>
  
  <pre><code>corona &lt;- data.frame(Cases = c(3, 16, 79, 157, 229, 322, 400, 650, 888, 1128, 1694, 2036, 2502, 3089, 3858), Date = seq(as.Date("2020/02/20"), as.Date("2020/03/05"), by = "days"))
  
  library(dplyr)
  corona_entire &lt;- corona %&gt;% mutate(Growth = (Cases - lag(Cases))/lag(Cases)*100)  
  
  mean(corona_entire$Growth[12:15])
  
  ff = function(x) x*(1.2285823)^60
  
  ff(3858)
  </code></pre>
  
  <p>However, in my function the growth rate (0.2285823) is constant over 60 periods. I would like to tell R to make that growth rate tend to 0 as we get closer and closer to 60. I need to write a convergence function for the growth rate basically.</p>
  
  <p>Any idea how can I code it?</p>
  
  <p>Thanks!</p>