Very thankful in advance.
I have a panel data in R of some non consecutive years (1821,1831,1832,1833,1837:1875) and population (pop) just for some of those years. I interpolated those missing values with "na_interpolation" function, such as:
Panel$pop_interp <- na_interpolation(Panel$pop)
The panel data is ordered by years. My individuals are "counties".
Panel <- Panel %>%
group_by(county, year) %>%
arrange(year)
With a nice column of "pop_interp" (interpolated values for population) I tried to compute a population growth rate with the following code:
Panel <- Panel %>%
mutate(growth_rate =(pop_interp / lag(pop_interp) - 1)*100)
And here the problem: the column of the growth rate is zero for all values. My question is, what am I doing wrong?
This is my first question on stack overflow, so please be merciful. I will provide everything I can to get some help from you :) Thanks again in advance. Best, Alejandra.
Here is how the panel data looks like at the end.
Explained above.