Moving to the Dark Side

Leaving the Pipette for a Keyboard.

Painless installation of R packages from source

I was minding my own business trying to add labels to a line plot in ggplot2. Then I saw that the package directlabels would solve all my problems with one single line of code. I proceed to install it using install.packages("directlabels", repo="http://r-forge.r-project.org"). Sadly:

package directlabels is not available (for R version 3.1.3)

Usually, I would download the source code, then use install.packages() from source. But this still did not work due some dependency issues. Thankfully there is the package devtools to help:

library(devtools)
install_url("http://cran.r-project.org/src/contrib/directlabels_2013.6.15.tar.gz")
library(directlabels)

As simple as that. It also allows installation from github repos.