Blog Archives

More useless statistics

August 22, 2011
By
More useless statistics

Over at the ExploringDataBlog, Ron Pearson just wrote a post about the cases when means are useless. In fact, it’s possible to calculate a whole load of stats on your data and still not really understand it. The canonical dataset for demonstrating this (spoiler alert: if you are doing an intro to stats course, you

Read more »

useR2011 highlights

August 18, 2011
By
useR2011 highlights

useR has been exhilarating and exhausting. Now it’s finished, I wanted to share my highlights. 10. My inner twelve year old schoolgirl swooning and fainting with excitement every time I chatted with a member of R-core. 9. Patrick Burns declaring that his company consists of himself and his two cats. And that one of the

Read more »

useR2011 Easy interactive ggplots talk

August 17, 2011
By
useR2011 Easy interactive ggplots talk

I’m talking tomorrow at useR! on making ggplots interactive with the gWidgets GUI framework. For those of you at useR, here is the code and data, so you can play along on your laptops. For everyone else, I’ll make the slides available in the next few days so you can see what you missed. Note

Read more »

Stop! (In the name of a sensible interface)

August 12, 2011
By
Stop! (In the name of a sensible interface)

In my last post I talked about using the number of lines in a function as a guide to whether you need to break it down into smaller pieces. There are many other useful metrics for the complexity of a function, most notably cyclomatic complexity, which tracks the number of different routes that code can

Read more »

Monster functions (Raaargh!)

August 12, 2011
By
Monster functions (Raaargh!)

It’s widely considered good programming practice to have lots of little functions rather than a few big functions. The reasons behind this are simple. When your program breaks, it’s much nicer to debug a five line function than a five hundred line function. Additionally, by breaking up your code into little chunks, you often find

Read more »

The Stats Clinic

July 27, 2011
By
The Stats Clinic

Here at HSL we have a lot of smart kinda-numerate people who have access to a lot of data. On a bad day, kinda-numerate includes myself, but in general I’m talking about scientists who have have done an introductory stats course, but not much else. When all you have is a t-test, suddenly everything looks

Read more »

The method in the mirror: reflection in R

July 17, 2011
By
The method in the mirror: reflection in R

Reflection is a programming concept that sounds scarier than it is. There are three related concepts that fall under the umbrella of reflection, and I’ll be surprised if you haven’t come across most of these code ideas already, even if you didn’t know it was called reflection. The first concept is examination of your variables.

Read more »

Testing for valid variable names

July 3, 2011
By
Testing for valid variable names

I have something a fondness for ridiculous variable names, so it’s useful to be able to check whether my latest concoction is legitimate. More so if it is automatically generated. Not having an is_valid_variable_name function is one of those odd omissions from R, and the assign function doesn’t check validity. To recap, there are a

Read more »

Tracking execution paths

June 18, 2011
By
Tracking execution paths

Earlier this week, I was trying to figure out the path of execution through a big chunk of code. Once you reach a certain size of codebase, tracking which function gets called when can be tricky. My first thought for dealing with this was to add a message line at the start of each function

Read more »

A clock utility, via console hackery

May 11, 2011
By
A clock utility, via console hackery

A discussion on StackOverflow today shows an interesting use of special characters inside the cat function. The most common special characters that you may have come across are the tab and newline characters, represented by \t and \n respectively. Try them for yourself. cat("Red\tlorry\nYellow\tlorry\n") cat also respects the backspace character, \b, and the carriage return

Read more »