title: melt dataframe and group by using dplyr calculations in R
body: <p>My sample data 
  `</p>
  
  <pre><code>structure(list(state = c("AP", "AP"), district = c("krishna", 
  "guntur"), rate = c(170104.5156, 1343.78134), growth_in_2016 = c(0.3844595, 
  0.3678), growth_in_2017 = c(0.444595, 0.8445), growth_in_2018 = c(0.323699, 
  0.36213), growth_in_2019 = c(0.5777, 0.35256), growth_in_2020 = c(0.2669097, 
  0.9097)), class = c("data.table", "data.frame"), row.names = c(NA,-2L), .internal.selfref = &lt;pointer: 0x00000000026c1ef0&gt;)
  </code></pre>
  
  <p>`</p>
  
  <p>I'm trying to group by state and district and then calculate monthly growth rate from yearly.</p>
  
  <p>Formula to calculate monthly is :(1+rates*growth_in_year)^(1/12) -1
  Correct me if am wrong </p>
  
  <p>`</p>
  
  <pre><code>state     district     date        rates
  AP        krishna    2016-12-31       x
  AP        krishna    2017-01-31       y
  AP        krishna    2017-02-28       z
  AP        krishna    2017-03-30       a
  AP        krishna    2017-04-31       b
  AP        krishna    2017-05-30       c
  AP        krishna    2017-06-31       d
  </code></pre>
  
  <p>and so onn for other district too.
  rates has to be in increasing order per each year for each district.
  I would like to have in date format rather than in year format. </p>