Setting Up the Development Version of R

August 28, 2012

My coworkers at Fred Hutchinson regularly use the development version of R (i.e., R-devel) and have urged me to do the same. This post details how I have set up the development version of R on our Linux server, which I use remotely because it is much faster than my Mac.

First, I downloaded the R-devel source into ~/local/, which is short for /home/jramey/local/ via Subversion, configured my installation, and compiled the source. I recommend these Subversion tips if you are building from source. Here are the commands to install R-devel.

svn co https://svn.r-project.org/R/trunk ~/local/R-devel
cd ~/local/R-devel
./tools/rsync-recommended
./configure --prefix=/home/jramey/local/
make
make install

The third command downloads the recommended R packages and is crucial because the source for the recommended R packages is not included in the SVN repository. For more about this, go here.

We have the release version (currently, it is 2.15.1) installed in /usr/local/bin. But the goal here is to give priority to R-devel. So, I add the following to my ~/.bashrc file:

PATH=~/local/bin:$PATH
export PATH

# Never save or restore when running R
alias R='R --no-save --no-restore-data --quiet'

Notice that the last line that I add to my ~/.bashrc file is to load R-devel quietly without saving or restoring.

Next, I install the R packages that I use the most.

install.packages(c('devtools', 'ProjectTemplate', 'knitr', 'ggplot2', 'reshape2',
                   'plyr', 'Rcpp', 'mvtnorm', 'caret'), dep = TRUE)

Here is my .Rprofile file:

.First <- function() {
  options(
    repos = c(CRAN = "http://cran.fhcrc.org/"),
    browserNLdisabled = TRUE,
    deparse.max.lines = 2
  )
}

# This code is copied directly from ?savehistory
# It saves the history of commands from interactive sessions to my home path
# when R is closed.
.Last <- function() {
  if (interactive()) try(savehistory("~/.Rhistory"))
}

if (interactive()) {
  suppressMessages(require(devtools))
}

Finally, my coworkers focus on flow cytometry data, and our group maintains several Bioconductor packages related to this type of data. To install the majority of them, we simply install the flowWorkspace package in R:

source("http://bioconductor.org/biocLite.R")
biocLite("flowWorkspace")

comments powered by Disqus