NOTE: These instructions will apply to the Unix version of R installed on Enigma and Usher. They do NOT apply to the Windows version.
The installation of R on Enigma and Usher comes installed with all of the packages froom CRAN and Bioconductor. However, you may want to install a non-CRAN/Bioconductor package or perhaps an updated version of a package on CRAN/Bioconductor. In order to do this you need to create a personal R package library.
Most R installations are set to install contributed packages (i.e. from CRAN or Bioconductor) in system directories. Unfortunately, users do not have permission to write to this directory. Usually, only system administrators can write to this directory (and this is for good reason!). However, it is not necessary to install contributed packages in system directories. They can in fact be installed anywhere.
Note that you do not have to install packages separately on Enigma and Usher. Since they share the same filesystem and architecture, you only need to install the package on Enigma and it will be available to you on Usher (and the cluster).
mkdir ~/RlibsNow you can install packages into this directory instead of the default system directory.
pkgName_x.y-z.tar.gzwhere x.y-z is the version number for the package. Some packages may not have the z number. Once you've copied this file on to Enigma you can install it with the command
R CMD INSTALL -l ~/Rlibs pkgName_x.y-z.tar.gzwhere, obviously, you should replace pkgName_x.y-z.tar.gz with the filename of the actual package you want to install. For example, if I wanted to install the tsModelSpec package, I would download the source package and save the file in my home directory on Enigma. Then issue the command (on Enigma)
R CMD INSTALL -l ~/Rlibs tsModelSpec_0.2.tar.gz
R_LIBS=~/Rlibsin the .Renviron file.
In R, you can install packages from CRAN in your personal package library by using the lib argument to install.packages. For example,
install.packages("gpclib", "~/Rlibs")installs the gpclib package in your personal package library.
Once you've created the .Renviron file you don't have to worry about it. Every time you start R, it will read the .Renviron file and register the location of your personal package library.
Unfortunately, you have to execute these steps every time you load up R because as soon as you quit, R forgets everything. The advantage of using the .Renviron method is that you only have to do it once.