Last month, together with the Exeter Initiative for Statistics and its Applications, Select hosted Talking Data South West the region’s first conference focusing on all aspects of data: from collection and analysis through to visualisation and communication. We were really pleased that Markus Gesmann joined us as one of our keynote speakers for the event. Not only is Markus an analyst at Lloyd’s of London, but in his spare time he is a keen user of R.
Markus’s talk was about the tools that he uses to communicate with his colleagues about ideas and concepts from his data analysis. He highlighted that whilst more and more data are becoming available, it is often difficult to find tools that allow us to identify key insights and to “bring the data to life”. One tool that Markus uses is the Motion Chart, which was first popularised by Hans Rosling (if you haven’t seen Hans’ TED talk we highly recommend you take a look!) and together with his colleague Diego de Castillo, Markus has developed a R package called googleVis that allows users to create their very own Motion Charts using R.
GoogleVis brings your data to life.
Inspired by Markus, I thought I would download the googleVis package and give it a go. The first thing I needed was a dataset to visualise. There are a few requirements for a Motion Chart since the data needs to have at least four variables: one identifying what we would like to plot, one time variable and at least two numerical variables (we need a variable for both the x and y-axes).
In this example I have chosen to use a data set only recently released to the general public: the House Price Index (HPI) background data from the Land Registry. These data include both the HPI and average house prices (our two numerical variables) for every month from 1995 to current (our time variable) broken down by Unitary Authority and Council (our identifier). I used one other piece of information for my Motion Chart – the location of each Unitary Authority/Council to see whether there is any evidence of a North-South divide (thanks to Kim Edmunds from Landmark Information Group for pointing this out!). To get this information I went to the Ordnance Survey Linked Data website and was able to extract the northings for each using some basic SQL commands (given below).
GoogleVis is essentially an interface between R and the Google Visualisation API and once I had my data in the right format it took only 3 lines of code to produce the Motion Chart below.
The house price index (HPI) is calculated using a record of all residential property transactions made in England and Wales since January 1995, which provides us with a reference period (the HPI value for all regions for January 1995 is 100). Using the play button the Motion Chart illustrates how average prices and the HPI have changed over time. Moving forward in time the plot demonstrates how both HPI and average house prices have increased over time until 2008/2009 where these values retract before increasing at a slower rate.
The colours represent the northings where Authorities/Councils in the North are coloured red/orange and those in the South blue. These highlight that there is a clear difference in house price between those in the South and those in the rest of the UK. (Note that if you hover over the bubbles the name of the region appears). It’s also possible to look at the data as a bar chart or line graph by selecting the tabs in the top left-hand corner.
We’ve only picked out some of the key points from this Motion Chart, but looking at the data in this way highlights many interesting features you might not normally see, not to mention being more interesting and fun than many standard charts! If you’ve got time series data we’d definitely recommend trying out using R to create a Motion Chart.
- Markus Gesmann and Diego de Castillo. Using the Google Visualisation API with R. The R Journal, 3(2):40-44, December 2011.
- HPI Data produced by Land Registry © Crown copyright 2013.
- Ordnance Survey data © Crown copyright and database right 2013.
(Note: to be added into the Linked Data query box)
PREFIX admingeo: <http://data.ordnancesurvey.co.uk/ontology/admingeo/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?uri ?name ?northing WHERE
?uri a admingeo:UnitaryAuthority .
?uri skos:prefLabel ?name .
?uri <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/northing> ?northing .
hpi_plot <- gvisMotionChart(hpi_final, idvar=”Unitary Authority”, timevar=”Date”, colorvar=”Northing”,sizevar=””)