library(openxlsx) sample1<-read.xlsx("http://kanggc.iptime.org/book/data/gdp-a.xlsx") y.ts<-ts(sample1$GDP, start=2000, end=2017, frequency=1) y.ts lagy<-lag(y.ts, k=-1) lagy gy<-(y.ts-lagy)/lagy*100 gy ly.ts<-log(y.ts) ly.ts gly<-(ly.ts-lag(ly.ts, k=-1))*100 gly agy<-mean(gy) agy gy.ts<-((y.ts[18]/y.ts[1])^(1/17)-1)*100 gy.ts plot(gy, type="l", lwd=3, col="red", main="Exact Growth Rate vs. Approx. Growth Rate of GDP") lines(gly, lwd=3, lty=6, col="green")