Last active
December 15, 2015 01:38
-
-
Save mages/5180860 to your computer and use it in GitHub Desktop.
World Bank data demo
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
# Thanks to John Maindonald | |
library(WDI) | |
indnams <- c("fertility.rate", "life.expectancy", | |
"population", "GDP.per.capita.Current.USD", | |
"15.to.25.yr.female.literacy") | |
inds <- c('SP.DYN.TFRT.IN','SP.DYN.LE00.IN', | |
'SP.POP.TOTL','NY.GDP.PCAP.CD', | |
'SE.ADT.1524.LT.FE.ZS') | |
wdiData <- WDI(country="all", indicator=inds, | |
start=1960, end=format(Sys.Date(), "%Y"), | |
extra=TRUE) | |
colnum <- match(inds, names(wdiData)) | |
names(wdiData)[colnum] <- indnams | |
## Create a motion chart | |
library(googleVis) | |
WorldBank <- droplevels(subset(wdiData, | |
!region %in% "Aggregates")) | |
M <- gvisMotionChart(WorldBank, | |
idvar="country", timevar="year", | |
xvar="life.expectancy", | |
yvar="fertility.rate", | |
colorvar="region", | |
sizevar="population", | |
options=list(width=550, height=500)) | |
## Display the chart in the browser | |
plot(M) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment