Check out R-bloggers for more excellent content!

R Recipe: Aligning Axes in ggplot2

2015-05-27     R

Faceted plots in ggplot2 are phenomenal. They give you a simple way to break down an array of plots according to the values of one or more categorical variables. But what if you want to stack plots of different variables? Not quite so simple. But certainly possible. I gathered together this solution from a variety of sources on stackoverflow, notably this one and this other one. A similar issue for vertical alignment is addressed here. Read more »

R Recipe: Reordering Columns in a Flexible Way

2015-05-16     R

Recent Common Ancestors: Simple Model

2015-05-15     R

An interesting paper (Modelling the recent common ancestry of all living humans, Nature, 431, 562–566, 2004) by Rohde, Olson and Chang concludes with the words: Read more »

R Recipe: Making a Chord Diagram


With the circlize package, putting together a Chord Diagram is simple. library(circlize) library(RColorBrewer) # Create a random adjacency matrix # adj = matrix(sample(c(1, 0), 26**2, replace = TRUE, prob = c(1, 9)), nrow = 26, dimnames = list(LETTERS, LETTERS)) adj = ifelse(adj == 1, runif(26**2), 0) chordDiagram(adj, transparency = 0.4, grid.col = "midnightblue", col = colorRamp2(seq(0, 1, 0.2), brewer.pal(6, "Blues")))

Comrades Marathon Finish Predictions

2015-04-23     R Running

Comrades Runners Disqualified: I'm Not Convinced

2015-04-16     Running

Apparently 14 runners have been disqualified for failing to complete the full distance at the 2012 and 2013 Comrades Marathons. I’m not convinced. Read more »

Encyclopaedia: Meteorites in Antarctica


A contribution which I wrote for Antarctica and the Arctic Circle: A Geographic Encyclopedia of the Earth’s Polar Regions. Read more »

A Sankey Plot with Uniform Coloured Edges

2015-04-07     R

Following up on my previous post about generating Sankey plots with the riverplot package. It’s also possible to generate plots which have constant coloured edges. Read more »

Encyclopaedia: Discovery Expedition


A contribution which Claire and I wrote for Antarctica and the Arctic Circle: A Geographic Encyclopedia of the Earth’s Polar Regions. Read more »

Bags, Balls and the Hypergeometric Distribution

2015-04-03     R

Comrades Marathon Pacing Chart: Up Run

2015-04-01     Excel Running

I’ve updated my Comrades Marathon pacing chart to include both the Up and Down runs. You can grab it here. The data for this year’s race are not yet finalised (I think we will be running 87 km), but you can make changes when it’s all confirmed. Read more »

The Price of Fuel: How Bad Could It Get?

2015-04-01     R

The cost of fuel in South Africa (and I imagine pretty much everywhere else) is a contentious topic. It varies from month to month and, although it is clearly related to the price of crude oil and the exchange rate, various other forces play an influential role. Read more »

Creating Charts with


Encyclopaedia: Geospace


A contribution which I wrote for Antarctica and the Arctic Circle: A Geographic Encyclopedia of the Earth’s Polar Regions. As a side note, I am normally quite pedantic about “Earth” and “Sun” being capitalised but the editor of the Encyclopaedia evidently had different views on this point. Read more »

Encyclopaedia: Scottish National Antarctic Expedition


A contribution which Claire and I wrote for Antarctica and the Arctic Circle: A Geographic Encyclopedia of the Earth’s Polar Regions Read more »

Font Awesome in Presentations: Notes

2015-03-22     Speaking

I’ve used various icons from Font Awesome in my last few presentations and I’ve been very pleased with the results. Using them is pretty straight forward, but here are a couple of things that I picked up: Read more »

Encyclopaedia: SANAE IV


A contribution which I wrote for Antarctica and the Arctic Circle: A Geographic Encyclopedia of the Earth’s Polar Regions. South Africa is one of the founding signatories of the Antarctic Treaty of 1959. In 1960, the first South African National Antarctic Expedition (SANAE) team overwintered at the Norwegian base on the Fimbul Ice Shelf. A new base, SANAE I, was constructed nearby (70° 18′S 2° 22′W) and opened in 1962. Later bases, SANAE II and SANAE III, were built on the same location (72° 40′ 22″S 2° 50′ 26″W) and commissioned in 1971 and 1979 respectively. Read more »

First Steps with Tableau: Decimal Separator

2015-03-13     Tableau

I downloaded a trial version of Tableau today and tried it out on one of the data sets I am currently working with. The data are stored in XLSX. Both the spreadsheet and my locale have a period set as the decimal separator, yet when I imported the data into Tableau it used a comma as the decimal separator. Read more »

Dealing with a Byte Order Mark (BOM)

2015-03-11     R

I have just been trying to import some data into R. The data were exported from a SQL Server client in tab-separated value (TSV) format. However, reading the data into R the “usual” way produced unexpected results: Read more »

Visualising Nobel Prizes and Laureates

2015-03-09     Visualisation

A very cool visualisation. Find out more at Read more »

Book Review: Graph Databases

2015-02-09     Neo4j Book Review

The book Graph Databases by Ian Robinson, Jim Webber and Emil Eifrem gives an engaging overview of Graph Databases, describing typical use cases and illustrating the syntax used to construct and query them. Graph Databases are a form of NoSQL database and, as such, differ significantly from the ubiquitous Relational Databases. The authors discuss a variety of scenarios where a Graph Database would be a better fit than a Relational Database, showing how they are particularly well suited to data which describe relationships between entities. Read more »

Book Review: R for Business Analytics

2015-01-28     R Book Review

The book R for Business Analytics by Ajay Ohri sets out to look at “some of the most common tasks performed by business analysts and helps the user navigate the wealth of information in R and its 4000 packages.” In my opinion it succeeds in covering an extensive range of topics but fails to provide anything of substantial use to its intended audience. At least, not anything that could not be uncovered by a brief internet search. Read more »

Downloading Options Data in R: An Update

2015-01-14     R

I recently read an article which showed how to download Option Chain data from Google Finance using R. Read more »

Random Number Generators

2014-12-19     talk: standard

Simulating Intricate Branching Patterns with DLA

2014-12-16     R

Manfred Schroeder’s book Fractals, Chaos, Power Laws: Minutes from an Infinite Paradise is a fruitful source of interesting topics and projects. He gives a thorough description of Diffusion-Limited Aggregation (DLA) as a technique for simulating physical processes which produce intricate branching structures. Examples, as illustrated below, include Lichtenberg Figures, dielectric breakdown, electrodeposition and Hele-Shaw flow. Read more »

Lessons I've Learned from Physics

2014-12-13     talk: standard

Rosetta's Rendezvous with Comet 67P


On 12 November 2014 the Philae lander from the Rosetta robotic space probe successfully landed on comet 67P/Churyumov–Gerasimenko. A couple of great comics to commemorate this momentous achievement. Read more »

Zacks Data on Quandl

2014-11-08     R

Data from Zacks Research have just been made available on Quandl. Registered Quandl users have free preview access to these data, which cover the following: Earnings Estimates: forward-looking consensus forecasts; Earnings Surprises: estimated future and actual historical earnings; Earnings Announcements: predictions for earnings announcement dates, parameters, and supplementary data; Sales Estimates: analogous to earnings estimates, but for sales; Dividend Data: dividend history and future announcement dates. These data describe over 5000 publicly traded US and Canadian companies and are updated daily. Read more »

Creating More Effective Graphs

2014-11-04     R

A few years ago I ordered a copy of the 2005 edition of Creating More Effective Graphs by Naomi Robbins. Somewhat shamefully I admit that the book got buried beneath a deluge of papers and other books and never received the attention it was due. Having recently discovered the R Graph Catalog, which implements many of the plots from the book using ggplot2, I had to dig it out and give it some serious attention. Read more »

Standard Bank: Striving for Mediocrity


Recently I was in my local Standard Bank branch. After finally reaching the front of the queue and being helped by a reasonably courteous young man, I was asked if I would mind filling out a survey. Sure. No problem. I had been in the bank for 30 minutes, I could probably afford another 30 seconds. Read more »