Unconstant Conjunction latest posts

Don't Forget to Reproject Spatial Data when Exporting to GeoJSON

In the process of working on a recent choropeth piece for work, I discovered that it’s easy to stumble when moving spatial data out of R and onto the web. It’s a poorly-documented reality that many web-based mapping libraries (including both D3 and Leaflet) expect GeoJSON data to be in EPSG:4326, and it is by no means a given that that your spatial data will start off in this projection.

If you’re like me and do your spatial data pre-processing in R before exporting to GeoJSON, you may have to re-project your data before these libraries will handle them properly. Thankfully, this is fairly easy to do with the modern spatial packages.

Continue Reading →

Forecasting YYZ Passengers in the Tidyverse

    2 March 2017 // tagged

Buried in the Toronto Economic Bulletin (warning: Excel document) is a column listing the number of passengers passing through Pearson International Airport (YYZ) each month, going back more than fifteen years. There’s a story to tell in the forecast, too:

Passengers at Pearson

Flight data are a great forecasting example because they display such clear seasonal patterns, in this case peaking in the summer months and falling off in the winter. R has excellent tools for working with time series data and whipping up simple forecasts like this one. But there’s some friction with the modern tidyverse tools, because the latter expect a data.frame as the common interchange format.

In this post, I’ll outline an approach to fitting many time series models using the tidyverse tools, including model selection for out-of-sample performance. To ease the transition between these two worlds I make extensive use of list columns and the broom package.

Continue Reading →

Using hledger with ledger-mode

    10 February 2017 // tagged

Last summer I landed a few patches in Emacs’s ledger-mode that make it easier to use with alternative implementations of Ledger, such as hledger. Since the competing hledger-mode garnered some attention last week on Hacker News, I thought these new features might be worth highlighting to those interested in plain-text accounting in Emacs.

Continue Reading →

An Update to the Choropleth Post

A few years ago I published a post outlining how to make nice-looking choropleth maps in R, and this piece still draws a reasonable share of my hits each month. Unfortunately, some of the techniques I used at the time are now quite out of date, and I was starting to feel bad for anyone taking my advice.

As of today the post has received a makeover, and takes a more modern approach. For any returning readers, the changes are explained in a series of HTML <ins> tags — which I have only recently discovered.

Continue Reading →

When do RcppEigen 'expressions' matter?

    27 September 2016 // tagged

Some time ago I discovered a very surprising performance issue while working with the Rcpp package, and thought I’d share the example I discovered.

Continue Reading →