Skip to content

Instantly share code, notes, and snippets.

@yutakashino
Created August 30, 2010 13:41
Show Gist options
  • Save yutakashino/557416 to your computer and use it in GitHub Desktop.
Save yutakashino/557416 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(WDI)
gdp <- WDI(country=c("US","JP","CN"), indicator="NY.GDP.MKTP.CD", start=1960, end=2008)
gdppercapita <- WDI(country=c("US","JP","CN"), indicator="NY.GDP.PCAP.CD", start=1960, end=2008)
gdpgrowth <- WDI(country=c("US","JP","CN"), indicator="NY.GDP.MKTP.KD.ZG", start=1960, end=2008)
ggplot(gdp, aes(year, NY.GDP.MKTP.CD, color=country))+geom_line(stat="identity")+theme_bw()+xlab("Year")+opts(title="GDP (current US$)")+ylab("")
ggsave(file='gdp.png')
ggplot(gdppercapita, aes(year, NY.GDP.PCAP.CD, color=country))+geom_line(stat="identity")+theme_bw()+xlab("Year")+opts(title="GDP per capita (current US$)")+ylab("")
ggsave(file='gdppercapita.png')
ggplot(gdpgrowth, aes(year, NY.GDP.MKTP.KD.ZG, color=country))+geom_line(stat="identity")+theme_bw()+xlab("Year")+opts(title="GDP growth (annual %)")+ylab("")
ggsave(file='gdpgrowth.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment