Blog Archives

Friday Function: nclass

May 6, 2011
By
Friday Function: nclass

When you draw a histogram, an important question is “how many bar should I draw?”. This should inspire an indignant response. You didn’t become a programmer to answer questions, did you? No. The whole point of programming is to let your computer do your thinking for you, giving you more time to watch videos of

Read more »

Friday function triple bill: with vs. within vs. transform

April 29, 2011
By
Friday function triple bill: with vs. within vs. transform

When you first learnt about data frames in R, I’m sure that, like me, you thought “This is a lot of hassle having to type the names of data frames over and over in order to access each column”. library(MASS) anorexia$wtDiff <- anorexia$Postwt - anorexia$Prewt #I have to type anorexia how many times? Indeed, any

Read more »

(Almost) Friday Function: alarm

April 21, 2011
By
(Almost) Friday Function: alarm

Last week I decided to start a weekly column detailing an interesting function each Friday, entirely forgetting that I would be on holiday, without internet access (shock horror!), tomorrow. So here’s your column a little early. The alarm function is something of a novelty, in that all it does is to make an annoying noise

Read more »

supercalifragilisticexpialidocious = 1

April 21, 2011
By
supercalifragilisticexpialidocious = 1

I notice that the latest version of R has upped the maximum length of variable names from 256 characters to a whopping 10 000! (See ?name.) It makes the 63 character limit in MATLAB look rather pitiful by comparison. Come on MathWorks! Let’s have the ability to be stupidly verbose in our variable naming! Tagged:

Read more »

Non-standard assignment with getSymbols

April 21, 2011
By
Non-standard assignment with getSymbols

I recently came across a rather interesting investment blog, Timely Portfolio. I have a certain soft spot for that sort of thing, because using my data analysis skills to make a fortune is casually on my to-do list. This blog makes regular use of a function getSymbols in the quantmod package. The power and simplicity

Read more »

Friday Function: setInternet2

April 15, 2011
By
Friday Function: setInternet2

Corporate IT networks are a pain for programmers. Ideally, when programming, you want the freedom to download, install and run any software that you want. Unfortunately, in the interests of security, many programmers find themselves a little restricted at the office. (I’m sure that many network admins will protest that the situation works both ways

Read more »

Legendary Plots

March 12, 2011
By
Legendary Plots

I was recently pointed in the direction of a thermal comfort model by the engineering company Arup (p27–28 of this pdf). Figure 3 at the top of p28 caught my attention. It’s mostly a nice graph; there’s not too much junk in it. One thing that struck me was that there is an awful lot

Read more »

A legitimate use for the stupidest variable name ever

February 2, 2011
By
A legitimate use for the stupidest variable name ever

The help page to make.names describes how to make a valid variable name in R: A syntactically valid name consists of letters, numbers and the dot or underline characters and starts with a letter or the dot not followed by a number. Names such as ‘”.2way”’ are not valid, and neither are the reserved words.

Read more »

Bad kitty!

January 20, 2011
By
Bad kitty!

The cat function bugs me a little. There are two quirks in particular that I find irritating on occasions that I use it. Firstly, almost everything that I want displayed onscreen, I want on its own line. > cat("cat messes up my command prompt position") cat messes up my command prompt position> So it would

Read more »

When 1 * x != x

January 16, 2011
By
When 1 * x != x

Trying to dimly recall things from my maths degree, it seems that in most contexts the whole point of the number one is that it is a multiplicative identity. That is, for any x in your set, 1 * x is equal to x. It turns out that when you move to floating point numbers,

Read more »