Stuff I Routinely Forget How to Do

A surprisingly important hunk of my bioinformatic skill set consists of Googling for error messages and implementing whatever fix the, say, StackOverflow posters suggested. I’ve collected the wisdom gleaned from such forums, man pages, and other programmers into this (newly relocated and expanded) document on GitHub: Stuff I Routinely Forget How to Do. I’m sure I’ll refer to it often and hopefully someone else will find it useful.


(Elephant photo by Flickr user guido da rozze.)

Named Colors in R

I spend too much time picking out colors for plots. R knows the names of 657 of them, but sometimes I don’t know if I’m in the mood for steelblue3 or steelblue4. I have this handy function in my .Rprofile file which takes a search string such as “blue” and returns a plot showing all colors with matching names.

plot.color.matches = function ( {

	matches = colors()[grep(, colors())]

	barplot(rep(1, length(matches)), col=matches, 
		pch=16, names=matches, las=2, cex.names=0.5, axes=FALSE)


You can call it with








to see all matching colors side by side.

R Named Colors - Blues


I’ve decided on “deepskyblue4″ for the current plot.

R, Procrastination, Kittens, and Dune

I’m currently in that strange liminality of the dissertation stage of grad school, which means I spend a lot of hours in a little closet in the library cursing quietly. The work is going well—I have little basis to complain—but occasionally I hit some snag with a program I’m writing. For me these headaches seems to happen more frequently in R, leading to events like the following:

I do this frequently enough to have created a bash alias:

But I got to thinking yesterday that a more fruitful approach than advising a hiatus would be a temporary distraction. I decided to write an R function that would show a picture of a puppy and an inspirational quote. Sadly I could not find free APIs that served puppy pictures or inspirational quotes. I settled for cats and quotes from the Dune novels. Now if I feel frustrated, I can call plot.kitty() and get something like these:

You can see the function (which was written sloppily in the span of about 20 minutes) at this GitHub Gist.