Making R growl

November 18, 2010
By

(This article was first published on Mario's Entangled Bank » R, and kindly contributed to R-bloggers)

Spending the day churning through large data set or doing some heavy-duty number crunching? What is one to do while the computer is running in overdrive? We’ll, for one, you could get a steaming cup of joe and write a post telling the world how you will know when the chomping and crunching is done. Some of you may say, just keep an eye on the program and/or the output. I say, that’s boring and not so practical when simultaneously running a dozen applications, each one with a fistful of windows spread out across 9 virtual desktops. Also, did I say it’s boring?

Anyway, imagine the following scenario; an Apple running snow leopard, R doing the number crunching, and a mint installation of Growl. Now, it would only make sense if R could display notifications through Growl, e.g. when the chomping and crunching is done. Well, as it turns out it can, all one has to do is to, more or less, follow the instructions of Michael Ewens. Turns out the current installation process is slightly different (easier?) and the implementation in R can be spiced up a snap. So, for the record, here is my version of the set up,

1. Install Growl and leave the disk image open.
2. Go to Growl-1.2.1/Extras/growlnotify
3. Run growlnotify.pkg

Now you are able to make R send notifications through Growl by declaring a one liner,

growl <- function(m = 'Hello world')
system(paste('growlnotify -a R -m '',m,'' -t 'R is calling'; echo 'a' ', sep=''))


There are a few twists to this version compared to previous incarnations, specifically, it gets the R application icon right, there is a system beep as part of the notification, and last but not least all this goodness is conveniently prepackaged as a short (aka oneliner) function, i.e. declare once and then unleash all the R growling you can think of like so

growl()


or even

growl('Ihr Befehl ist fertiger Meister')


Oops, there it goes. Gotta go…

This is from the “Mario’s Entangled Bank” blog (http://pineda-krch.com) of Mario Pineda-Krch, a theoretical biologist at the University of Alberta.

Filed under: R