I’ve been following the development of googleVis, the implementation of the Google Visualization API for R, for a bit now. The library has a lot of potential as a bridge between R (where data processing happens) and HTML (where presentation is [increasingly] happening). A growing number of visualization frameworks are on the market and all have their perks (e.g. Many Eyes, Simile, Flare). I guess I was inspired in such a way by the Hans Rosling Show TED talk that makes such great use of bubble charts that I wanted to try the Google Vis API for that chart type alone. There’s more, however, if you don’t care much for floating blubbles: neat chart variants include the geochart, area charts and the usual classics (bar, pie, etc). Check out the chart gallery for an overview.

So here are my internet growth charts:

(1) Motion chart showing the growth of the global internet population since 2000 for 208 countries

(2) World map showing global internet user statistics for 2009 for 208 countries

Data source: data.un.org (ITU database). I’ve merged two tables from the database into one (absolute numbers and percentages) and cleaned the data up a bit. The resulting tab-separated CSV file is available here.

And here’s the R code for rendering the chart. Basically you just replace gvisMotionChart() with gvisGeoChart() for the second chart, the rest is the same.

1
2
3
4
library("googleVis")
n <- read.csv("netstats.csv", sep="\t")
nmotion <- gvisMotionChart(n, idvar="Country", timevar="Year", options=list(width=1024, height=768))
plot(nmotion)
Tagged with:  

3 Responses to Visualizing China’s internet growth with R and the Google Visualization API

  1. Really nice this post on googleVis and R. I run your CSV test file and the chart is gorgeous. But I can’t seem to make googleVis to read the date format in my files. I’ve tried pretty much everything: %Y/%m/%d; YYYY-mm-dd; YY, mm, dd; and whatever variation with delimiters you might possibly think. Yes, I tried the American format and checked the Java Date format. It should have worked but it didn’t. Except for single year columns like the dataset you used I keep getting the error message “The timevar has to be of numeric or Date format. Currently it is factor”. Did you go thru this as well?

  2. cornelius says:

    Hmm, no, not that I recall. Have your tried as.POSIXct()? That’s what I’ve used to turn regular strings/factors into items that R treats as actual dates.

  3. Toby says:

    I am new to R, and expeimenting with this visualisation, unfortuantely I too have the same problem of getting the date wrong
    “The timevar has to be of numeric or Date format. Currently it is factor”
    no matter what I do – the data is in .csv format with the second column labelled “Month”
    and in the date format day/month/year
    I really just need the month? any help would be greatly appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>