Publications by richierocks

GUI building in R: gWidgets vs Deducer

20.02.2012

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 including tcltk, GTK, qt, and Java, not to menti...

2831 sym R (3494 sym/3 pcs) 4 img

Benford’s Law and fraud in the Russian election

05.03.2012

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 the contents with R, for a single document i...

1550 sym R (1464 sym/8 pcs) 8 img

Be assertive!

30.05.2012

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. is_a_number(1) #TRUE is_a_number("a") #FALSE is_a_numbe...

2438 sym R (414 sym/5 pcs) 6 img

How long does it take to get pregnant?

15.06.2012

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 this isn’t...

2933 sym R (901 sym/3 pcs) 6 img

Look ma! No typing! Autorunning code on R startup

20.07.2012

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 science. My tool of ch...

3329 sym R (515 sym/5 pcs) 4 img

Make your data famous!

30.10.2012

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 only constraint is that it can be a...

1737 sym 4 img

Indexing with factors

08.11.2012

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 gender. (heights <- data.frame(...

1937 sym R (574 sym/5 pcs) 4 img

Have my old job!

14.11.2012

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, preferably R or MATLAB or...

1314 sym 4 img

A brainfuck interpreter for R

24.04.2013

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 index left or right along th...

2197 sym R (975 sym/1 pcs) 4 img

user2013: The Rcpp tutorial

09.07.2013

I’m at user 2013, and this morning I attended Hadley Wickham and Romain Francois’s tutorial on the Rcpp package for calling C++ code from R. I’ve spent the last eight years avoiding C++ afer having nightmares about obscure pointer bugs, so I went into the room slightly skeptical about this package. I think the most important takeaway from ...

3427 sym R (350 sym/4 pcs) 4 img