Publications by Tony Hirst

Segmenting F1 Qualifying Session Laptimes

29.03.2015

I’ve started scraping some FIA timing sheets again, including practice and qualifying session laptimes. One of the things I’d like to do is explore various ways of looking at the qualifying session laptimes, which means identifying which qualifying session each laptime falls into: For looking at session utilisation charts I’ve been making ...

3072 sym R (727 sym/3 pcs) 14 img

Iteratively Populating Templated Sentences With Inline R in knitr/Rmd

29.03.2015

As part of the Wrangling F1 Data With R project, I want to be able to generate sentences iteratively from a templated base. The following recipe works for sentences included in an external file: What I’d really like to be able to do is put the Rmd template into a chunk something like this…: ```{rmd stintPara, eval=FALSE, echo=FALSE} `r name`...

875 sym R (401 sym/2 pcs) 8 img

Mixing Numbers and Symbols in Time Series Charts

08.04.2015

One of the things I’ve been trying to explore with my #f1datajunkie projects are ways of representing information that work both in a glanceable way as well as repaying deeper reading. I’ve also been looking at various ways of using text labels rather than markers to provide additional information around particular data points. For example, i...

4713 sym R (1002 sym/1 pcs) 12 img

A Couple of Handy ggplot Tricks – Using Environmental Variables and Saving Charts

12.04.2015

A couple of handy tricks when working with ggplot that had escaped my radar until today. First up, I had a problem in a function I was using to generate a ggplot2 in which I wanted to accept a couple of optional arguments in to the function and then make use of them in a ggplot aes() element. Normally, ggplot will try to dereference a variable as...

2641 sym R (1304 sym/2 pcs) 6 img

Wrangling Complex Spreadsheet Column Headers

14.04.2015

[This isn’t an R post, per se, but I’m syndicating it via RBloggers because I’m interested – how do you work with hierarchical column indices in R? Do you try to reshape the data to something tidier on the way in? Can you autodetect elements to help with any reshaping?] Not a little p****d off by the Conservative election pledge to extend...

3594 sym Python (1979 sym/9 pcs) 24 img

Scraping Web Pages With R

15.04.2015

One of the things I tend to avoid doing in R, partly because there are better tools elsewhere, is screenscraping. With the release of the new rvest package, I thought I’d have a go at what amounts to one of the simplest webscraping activites – grabbing HTML tables out of webpages. The tables I had in my sights (when I can actually find them�...

2591 sym R (2433 sym/2 pcs) 8 img

Keeping Track of an Evolving “Top N” Cutoff Threshold Value

26.04.2015

In a previous post (Charts are for Reading), I noted how it was difficult to keep track of which times in an F1 qualifying session had made the cutoff time as a qualifying session evolved. The problem can be stated as follows: in the first session, with 20 drivers competing, the 15 drivers with the best ranked laptime will make it into the next s...

5035 sym Python (867 sym/1 pcs) 8 img

IPython Markdown Opportunities in IPython Notebooks and Rstudio

06.06.2015

One of the reasons I started working on the Wrangling F1 Data With R book was to see what the Rmd (RMarkdown) workflow was like. Rmd allows you to combine markdown and R code in the same document, as well as executing the code blocks and then displaying the results of that code execution inline in the output document. As well as rendering to HTM...

3486 sym 14 img

Notebooks, knitr and the Language-Markdown View Source Option…

08.06.2015

One of the foundational principles of the web, though I suspect ever fewer people know it, is that you can “View Source” on a web page to see what bits of HTML, Javascript and CSS are used to create it. In the WordPress editor I’m currently writing in, I’m using a Text view that lets me write vanilla HTML; but there is also a WYSIWYG (wha...

1611 sym 12 img

Spotting Potential Battles in F1 Races

10.06.2015

Over the last couple of races, I’ve started trying to review a variety of battlemaps for various drivers in each race. Prompted by an email request for more info around the battlemaps, I generated a new sketch charting the on track gaps between each driver and the lap leader for each lap of the race (How the F1 Canadian Grand Prix Race Evolved ...

2663 sym R (1311 sym/1 pcs) 6 img