Skip to content

Instantly share code, notes, and snippets.

@izamryan
Last active December 21, 2015 10:59
Show Gist options
  • Save izamryan/6295914 to your computer and use it in GitHub Desktop.
Save izamryan/6295914 to your computer and use it in GitHub Desktop.
Analysis of #ASEAN #econometrics in #Rstats
library(WDI)
library(ggplot2)
library(zoo)
countries <- c('BN','ID','MY','PH','SG','TH','KH','LA','MM','VN')
indicators <- 'NY.GDP.MKTP.KD.ZG'
dat = WDI(indicator='NY.GDP.MKTP.KD.ZG', country=countries, start=1982, end=2012)
ggplot(dat, aes(year, NY.GDP.MKTP.KD.ZG, color=country)) + geom_line()
+ xlab('Year') + ylab('GDP growth')
+ labs(title = "GDP growth")
BN.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='BN', start=1982, end=2012)
ID.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='ID', start=1982, end=2012)
MY.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='MY', start=1982, end=2012)
PH.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='PH', start=1982, end=2012)
SG.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='SG', start=1982, end=2012)
TH.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='TH', start=1982, end=2012)
KH.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='KH', start=1982, end=2012)
LA.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='LA', start=1982, end=2012)
MM.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='MM', start=1982, end=2012)
VN.gdpx=WDI(indicator='NY.GDP.MKTP.KD.ZG', country='VN', start=1982, end=2012)
BN.gdpx <- BN.gdpx[,4:3]
ID.gdpx <- ID.gdpx[,4:3]
MY.gdpx <- MY.gdpx[,4:3]
PH.gdpx <- PH.gdpx[,4:3]
SG.gdpx <- SG.gdpx[,4:3]
TH.gdpx <- TH.gdpx[,4:3]
KH.gdpx <- KH.gdpx[,4:3]
LA.gdpx <- LA.gdpx[,4:3]
MM.gdpx <- MM.gdpx[,4:3]
VN.gdpx <- VN.gdpx[,4:3]
colnames(BN.gdpx) <- c("Year","BN")
colnames(ID.gdpx) <- c("Year","ID")
colnames(MY.gdpx) <- c("Year","MY")
colnames(PH.gdpx) <- c("Year","PH")
colnames(SG.gdpx) <- c("Year","SG")
colnames(TH.gdpx) <- c("Year","TH")
colnames(KH.gdpx) <- c("Year","KH")
colnames(LA.gdpx) <- c("Year","LA")
colnames(MM.gdpx) <- c("Year","MM")
colnames(VN.gdpx) <- c("Year","VN")
GDP.z <- merge(BN.gdpx,ID.gdpx)
GDP.z <- merge(GDP.z,MY.gdpx)
GDP.z <- merge(GDP.z,PH.gdpx)
GDP.z <- merge(GDP.z,SG.gdpx)
GDP.z <- merge(GDP.z,TH.gdpx)
GDP.z <- merge(GDP.z,KH.gdpx)
GDP.z <- merge(GDP.z,LA.gdpx)
GDP.z <- merge(GDP.z,MM.gdpx)
GDP.z <- merge(GDP.z,VN.gdpx)
GDP.z <- zoo(GDP.z)
plot(rollapply(GDP.z,FUN=mean,width=5,align="right"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment