How the BBC uses R for data visualisation
Joanne Kuai
22, February 2019 | London
Over the past year, data journalists on the BBC Visual and Data Journalism team have fundamentally changed how they produce graphics for publication on the BBC News website. And one tool proves to be of great help – R, a programming language and free software environment for statistical computing and graphics.
“Data team had been using R for analysis for a long time, but charts mostly made either in our in-house chart tool or by design team. Sometimes we use R for exploratory graphics using R’s ggplot2 package that we’d bring to designers. We started thinking we should try making graphics that were ready to be published on the site instead,” said John Walton and Nassos Stylianou.
“Data journalists already using R for analysis – instead of having to commission lots of charts from the designers, we come to learn that we can do everything in R, which is faster and a much less clunky workflow. As an added bonus the designers are freed up to focus more on bespoke graphics and illustrations,” said John.
“Now we have a dozen people regularly making charts using ggplot and number of charts is in the hundreds.”
From ggplot to bbplot
Moving beyond making just charts, the team is increasingly also making static maps in R.
Making small multiples is easy, and it is also easy to update them with new data. For example, they are able to create hurricane maps from start to finish in R just by updating the URL to download the latest shapefiles from the National Hurricane Center.
The team have also created an R package called bbplot – a collection of functions that solves specific tasks. “This does two things: replaces the ggplot default style with our in-house style and saves out the finished chart,” said John.
In addition, the BBC’s visual journalism department has created the R Cookbook, the technical and style guidelines for data-driven charts of all kinds. The technology simplifies the creation of charts as well as drives greater accuracy of plotting a variety of styles of charts, such as scatter, bar, fever, dumbbell and other charts into the correct BBC style.
“The cookbook, meanwhile, is a guidebook in which we gather the team’s collected knowledge of ggplot2. A reference manual, rather than a tutorial, it might not tell you how to make your very first chart in R, but is a useful collection of little tips and tricks,” says Nassos.
“The idea is that whenever a member of the data team solves a specific problem, like adding curved arrows to a plot or highlighting a single bar in a bar chart, the code is added to the cookbook to save you and colleagues time next time.”
Beyond the data team
To help other colleagues at the BBC, the data team also developed a six-week course for design and editorial colleagues in editorial, design and dev teams, with the aim of helping them to gain a basic understanding of R and data manipulation, but geared towards producing graphics.
“Each week we introduce one concept, talk it through with them and point them to online tutorials they can complete over the course of the week. Over the six weeks, participants go through how to load data into R, different data types, some very basic data manipulation and analysis in R using tidyverse packages as well as an introduction into ggplot2,” says Nassos.
John and Nassos were speaking at the Product Development and Design Thinking Summit, which took place in London 21-22 February 2019. As part of the 9th Data & AI for Media Week, the event aims to inspire participants to imagine how to earn revenue with AI-driven products for their own media companies.
The Data & AI for Media Week was created by the World Newsmedia Network in 2013. Since then, the conference has been held in London five times, Hong Kong once and twice in New York. The 10th Data & AI for Media Week is planned for San Francisco and Silicon Valley for 29 April to 3 May 2019. https://sanfrancisco.dataaimedia.org/
Bbplot: http://bit.ly/bbcbbplot
BBC R cookbook: http://bit.ly/bbcrcookbook