Chart MakeoveR

Working out with (geom) dumbbells

There is quite a lot of information on there, but bar charts are not perhaps the best choice for visualising data over time.

This is not to be critical - it gets a lot of data across in one plot, but I thought it would be interesting to have a bash at displaying the data using R, using my go-to graphics package, ggplot2.

By the way, for those who don’t know - the SIMD is the Scottish Index of Multiple Deprivation, which “identifies small area concentrations of multiple deprivation across all of Scotland in a consistent way.

It allows effective targeting of policies and funding where the aim is to wholly or partly tackle or take account of area concentrations of multiple deprivation”.
(Courtesy of the Scottish Govt website). So each postcode in Scotland is assigned to a datazone, and those datazones are ranked on the SIMD - see the link for more information.

I knew that this would be ideal for faceting (one of the key strengths of ggplot2 - basically creating small multiples, using a couple of different display options, namely geom_grid or geom_wrap).

I created a simple text file reading the values from the original bar chart, and loaded that up into R. I also created a variable for faceting the plot easily. This required that the labels be re-ordered:

Notice the nice subtitle below the main title - this is due to the sterling work of Bob Rudis - who created this functionality and which is now in in the development version of ggplot2 on github.
For more information on this, please see Bob’s blog post here.

This clearly shows the change over time amongst the deciles. I kept the facet labels colouring consistent, so as not to distract. In an earlier version, I’d annotated the red target line as such but it didn’t look very good when viewing the final plot.

As a simple alternative, this works quite well. However, I’d seen another blog post by Bob Rudis - (who, you may have gathered, is a ggplot2 / R guru), where he demonstrated his newest creation - dumbbell plots : exercising-with-ggalt-dumbbells.

I wanted to give this a try, so, armed with a fresh install of Bob’s package ggalt, I produced the following:

I’d already managed to get the value labels either side of the dumbell points, but I needed Bob’s blog code to get the Year values to appear above the points for SIMD 10.

Throughout this work, I faced some challenges - probably self inflicted!

For one, I was struggling to filter my “data3” dataframe for a specific SIMD. Then I remembered that this was a factor, not a character. I didn’t want to risk breaking the working code elsewhere, and I realised I need to filter on the factor levels, but could not get the correct syntax.