I have to calculate the inflation rate from 1990-2010. I have to do this with the CPI, which I have for each month for the 20 years. This means that I have to calculate the percentage growth rate for the same month of the previous year.
My teacher gave me this code:
n <- length(cpi)
infl <- cpi[13:n]/cpi[1:(n-12)]
Can somebody explain me the code and how I can use it?