Suppose I have a data frame 'country' with 3 colums:
- year (ranging from 2000 to 2017)
- GDP
- Population
My objective is to grow the GDP and population for the next five years according to assumptions. I have developped the following loop:
country[19:23,1] <- seq(2018, by=1, length.out = 5)
for (i in 19:nrow(country)){
country[i,"GDP"] <- country[i-1, "GDP"] * (1 + hypo_gdp/100)
country[i,"Population"] <- country[i-1, "Population"] * (1 + hypo_pop/100)
}
Where hypo_gdp and hypo_pop are my growth assumptions.
Is there a way to use one of the apply() functions in this case?
Thanks in advance!