I had a bit of a play with Shiny over the weekend, using the Ergast Motor Racing Data API and the magical Shiny library for R, that makes building interactive, browser based applications around R a breeze.
As this is just a quick heads-up/review post, I’ll largely limit myself to a few screenshots. When I get a chance, I’ll try to do a bit more of a write-up, though this may actually just take the form of more elaborate documentation of the app, both within the code and in the form of explanatory text in the app itself.
If you want to try ou the app, you can find an instance here: F1 2012 Laptime Explorer. The code is also available.
Here’s the initial view – the frist race of the season is selected as a default and data loaded in. The driver list is for all drivers represented during the season.
THe driver selectors allow us to just display traces for selected drivers.
The Race History chart is a classic results chart. It show the difference between the race time to date for each driver, by lap, compared to the average lap time for the winner times the lap number. (As such, this is an offline statistic – it is calculated when the winner’s overall average laptime is known).
Variants of the classic Race History chart are possible, for example, using different base line times, but I haven’t implemented any of them – or the necessary UI controls. Yet…
The Lap Chart is another classic:
Annotations for this chart are also supported, describing all drivers who final status was not “Finished”.
The Lap Evolution chart shows how each driver’s laptime evolved over the course of the race compared with the fastest overall recorded laptime.
The Personal Lap Evolution chart shows how each driver’s laptime evolved over the course of the race compared with their personal fastest laptime.
The Personal Deltas Chart shows the difference between one laptime and the next for each driver.
The Race Summary Chart is a chart of my own design that tries to capture notable features relating to race position – the grid position (blue circle), final classification (red circle), position at the end of the first lap (the + or horizontal bar). The violin plot shows the distribution of how many laps the driver spent in each race position. Where the chart is wide, the driver spent a large number of laps in that position.
The x-axis ordering pulls out different features about how the race progressed. I need to add in a control that lets the user select different orderings.
Finally, the Fast Lap text scatterplot shows the fastest laptime for each driver and the lap at which they recorded it.
So – that’s a quick review of the app. All in all it took maybe 3 hours getting my head round the data parsing, 2-3 hours figuring what I wanted to do and learning how to do it in Shiny, and a couple of hours doing it/starting to document/annotate it. Next time, it’ll be much quicker…
3 thoughts on “More Shiny Goodness – Tinkering With the Ergast Motor Racing Data API”
Love it–thanks for sharing!
For all you numbers geeks out there – check out this free site showing all kinds of comparison graphs for F1. I love the gap-to-leader chart. Very cool. http://www.themajordomo.com
Comments are closed.