Hi,
I am trying to build a loop which calculates the value of a GDP at date t thanks to the value at t-1 and the growth rate. However, I would like this loop to make the computation in every country independently. I could not find any easy way to do this and my skills are not developed enough to use lapply alone yet. Do you have any hint to do this ?
The loop I have for now:
for (i in 2:length(iso)) {
GDP_value[i] <- (GDP_value[i-1])*(1+GDP_growth[i])
}
What I want is the loop to start again when iso have new value and so does not use the previous value of GDP.