R interface to Google Chart Tools

Hans Rosling eat your heart out! It is now possible to interface R statistics software to Google’s Gapminder inspired Chart Tools. The plots below were produced using the googleVis R package and three datasets from the Gapminder website. The first shows the relationship between income, life expectancy and population for 20 countries with the highest life expectancy in 1979 and the bottom plot shows the countries with the lowest 1979 life expectancy. Press play to see how the countries have faired over the past 50 years. You can also change the variables represented on each axes, the colours and the variable that controls the size of the bubbles.

Data: all_date, Chart ID: MotionChart_2011-01-10-10-16-25
R version 2.12.1 (2010-12-16),

Google Terms of Use


Data: all_date, Chart ID: MotionChart_2011-01-10-10-10-46
R version 2.12.1 (2010-12-16),

Google Terms of Use

It was a bit fiddly to get the data formatted correctly and I couldn’t manage to get the complete dataset in one plot because my browser kept crashing (Chrome is best). Even with these teething problems it is a great way to get people creating better visualizations with their data. If you want to see Hans Rosling demonstrating these plots with his trademark enthusiasm I thoroughly recommend “The Joy of Stats” a program produced for the BBC. You can watch it here.
For those who want to create their own plots, I’m not proud of the code I used to format the data above so to get you started try this example (provided with the package).
library(googleVis)
data(Fruits)
M1 <- gvisMotionChart(Fruits, idvar=”Fruit”, timevar=”Year”)
plot(M1)
Thanks to the Recology blog for promoting this.