Unconstant Conjunction latest posts

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 →

Exporting Clock Entries from org-mode to CSV

If you’ve used the clocking features of org-mode, you’re no doubt familiar with the clock table, which allows you to summarise time spent on different tasks. This is great for getting an overview of projects, but it’s not a very flexible tool if you want to have a more detailed idea of how you spend your time.

At this point I’ve accumulated about a year’s worth of clocked work time in org, and while clock tables have served me well so far, eventually I just wanted to get my data into R or Python for more minute analysis, and charts like the following:

Calendar heatmap example

However, I haven’t come across a reliable1 way to get individual clock entries out of org-mode files and into a more widely readable format. So I’ve written one.

Continue Reading →

Custom Hexbin Functions with ggplot

Recently, I wanted to create a map similar to James Cheshire’s crime map of London, which shows the most common crimes commited in a rectangular grid of points laid over London. Instead of using a rectangular grid, I wanted to use hexbins, but it turns out that ggplot needs a bit of prodding to do anything other than simply count the number of observations in each bin.

At the time I couldn’t find a good tutorial on writing custom hexbin functions, so this post is a reasonably thorough explanation of what I’ve made work.

Continue Reading →

Linting Prose in Emacs

    10 February 2016 // tagged

Recently, I came across the Proselint project, which aspires to be something like a “linter” for written English prose. It differs from spelling or grammar checker in that it is primarily focused on logic and style, taking its advice from the work of many prominent writers on writing.

The project seems to be a little rough around the edges (code blocks seem to make it struggle, for example), but it’s also perfectly usable in its current form. It’s available as a Python package, so you can pip install proselint to get the command-line tool, proselint.

Thanks to the Flycheck framework it’s comically easy to get this imported into a Emacs writing environment. The following snippet will get you up and running in text and markdown modes:

(flycheck-define-checker proselint
  "A linter for prose."
  :command ("proselint" source-inplace)
  :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": "
	    (id (one-or-more (not (any " "))))
	    (message) line-end))
  :modes (text-mode markdown-mode gfm-mode))

(add-to-list 'flycheck-checkers 'proselint)

Continue Reading →