Blog Archives

A brainfuck interpreter for R

April 24, 2013
By
A brainfuck interpreter for R

The deadline for my book on R is fast approaching, so naturally I’m in full procrastination mode.  So much so that I’ve spent this evening creating a brainfuck interpreter for R.  brainfuck is a very simple programming language: you get an array of 30000 bytes, an index, and just 8 eight commands.  You move the

Read more »

Have my old job!

November 14, 2012
By
Have my old job!

My old job at the Health & Safety Laboratory is being advertised, and at a higher pay grade to boot.  (Though it is still civil service pay, and thus not going to make you rich.) You’ll need to have solid mathematical modelling skills, particularly solving systems of ODEs, and be proficient at writing scientific code,

Read more »

Indexing with factors

November 8, 2012
By
Indexing with factors

This is a silly problem that bit me again recently. It’s an elementary mistake that I’ve somehow repeatedly failed to learn to avoid in eight years of R coding. Here’s an example to demonstrate. Suppose we create a data frame with a categorical column, in this case the heights of ten adults along with their

Read more »

Make your data famous!

October 30, 2012
By
Make your data famous!

I’m writing a book on R for O’Reilly, and I need interesting datasets for the examples. Any data that you provide will get you a mention in the book and in the publicity material, so it’s a great opportunity to publicise your work or your organisation. Datasets from any area or industry are suitable; the

Read more »

Look ma! No typing! Autorunning code on R startup

July 20, 2012
By
Look ma! No typing! Autorunning code on R startup

Regular readers may know that I often make R-based GUIs. They’re great for giving non-technical users safe and easy access to statistical models. The safety comes from the restrictions of a GUI: you can limit what the users does more easily than with a command line, helping to reduce the number of opportunities for bad

Read more »

How long does it take to get pregnant?

June 15, 2012
By
How long does it take to get pregnant?

My girlfriend’s biological clock is ticking, and so we’ve started trying to spawn. Since I’m impatient, that has naturally lead to questions like “how long will it take?”. If I were to believe everything on TV, the answer would be easy: have unprotected sex once and pregnancy is guaranteed. A more cynical me suggests that

Read more »

Be assertive!

May 30, 2012
By
Be assertive!

assertive, my new package for writing robust code, is now on CRAN. It consists of lots of is functions for checking variables, and corresponding assert functions that throw an error if the condition doesn’t hold. For example, is_a_number checks that the input is numeric and scalar. In the last two cases, the return value of

Read more »

Benford’s Law and fraud in the Russian election

March 5, 2012
By
Benford’s Law and fraud in the Russian election

Earlier today Ben Goldacre posted about using Benford’s Law to try and detect fraud in the Russian elections. Read that now, or the rest of this post won’t make sense. This is a loose R translation of Ben’s Stata code. The data is held in a Google doc. While it is possible to directly retrieve

Read more »

GUI building in R: gWidgets vs Deducer

February 20, 2012
By
GUI building in R: gWidgets vs Deducer

I’ve been a user (and fan) of gWidgets for a couple of years now for GUI building in R. (See my introduction to it here.) However, it’s always good to check out the competition so I’ve been playing around with Deducer to see how they compare. R can access a number of GUI building frameworks

Read more »

R hits 10000 questions on stackoverflow

February 17, 2012
By
R hits 10000 questions on stackoverflow

A milestone, though not that exciting as questions go. Still, if you haven’t yet joined the cult of Stack Exchange, take a look here. Tagged: r, stackoverflow

Read more »