Using R

Installing R Packages

If you wish to install additional packages for R we recommend they be installed to your home directory on Brazos. In the examples below $HOME/R/lib is used, but any path under $HOME will work.

First create your R_LIBS_USER directory and set the environment variable. Example:

mkdir -p $HOME/R/lib
export R_LIBS_USER=$HOME/R/lib
If you wish for the R_LIBS_USER environment variable to be set upon login, you can add the export line to your .bashrc file.

The example code below goes into your $HOME/.Rprofile. The code in the example will set the package download mirror so you are not prompted during each install of a package.

message("Loading .Rprofile")
r <- getOption("repos")             # hard code the US repo for CRAN
r["CRAN"] <- ""
options(repos = r)
Now you can install a package. This example uses the intel/2013_sp1.3 and R/3.1.1 modules, but others are available. You can find the available R modules by executing module spider R.
module load intel/2013_sp1.3 R/3.1.1
The following commands are executed from the R shell.
> install.packages("likelihood")
Installing package into ‘/home/treydock/R/lib’
(as ‘lib’ is unspecified)
trying URL ''
Content type 'application/x-gzip' length 37620 bytes (36 Kb)
opened URL
downloaded 36 Kb

Loading .Rprofile
* installing *source* package ‘likelihood’ ...
** package ‘likelihood’ successfully unpacked and MD5 sums checked
** R
** data
** demo
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Loading .Rprofile
* DONE (likelihood)

The downloaded source packages are in
You can now verify the likelihood package was installed from the R shell.
> (.packages(all.available=TRUE))
 [1] "likelihood" "base"       "boot"       "class"      "cluster"
 [6] "codetools"  "compiler"   "datasets"   "foreign"    "graphics"
[11] "grDevices"  "grid"       "KernSmooth" "lattice"    "MASS"
[16] "Matrix"     "methods"    "mgcv"       "nlme"       "nnet"
[21] "parallel"   "rpart"      "spatial"    "splines"    "stats"
[26] "stats4"     "survival"   "tcltk"      "tools"      "utils"