Created
December 5, 2010 19:20
-
-
Save Protonk/729369 to your computer and use it in GitHub Desktop.
Ended up not needing this for the previous post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(WDI) | |
growth.df<-WDI(country="all",indicator="NY.GDP.MKTP.KD.ZG",start=1961,end=2009,extra=TRUE); | |
growth.df<-subset(growth.df,growth.df$region != "Aggregates") | |
growth.df<-growth.df[,c(2:4)] | |
names(growth.df)<-c("country","year","growth") | |
growth.df$country<-as.factor(growth.df$country) | |
#TS stuff | |
pre.ts<-cast(melt.data.frame(growth.df,id.vars=c("country","year")),year~country); | |
growth.ts<-ts(pre.ts,start=1961,end=2009,frequency=1) | |
diff.ts<-diff(growth.ts) | |
diff.mult<-as.data.frame(unclass(diff.ts)) | |
diff.mult<-diff.mult[,-1] | |
diff.long<-melt(diff.mult) | |
diff.long$year<-rep(seq(1962,2009,1),213) | |
names(diff.long)<-c("country","diff","year") | |
diff.means<-ddply(diff.long,.(year),summarise,var=var(diff,na.rm=TRUE),mean=mean(diff,na.rm=TRUE)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment