Installing the R Project for Statistical Computing
The R Project is a language and environment for statistical computing and graphics.
To install R download the tarball to an appropriate place and extract e.g.,
cd /usr/local/src/R
wget http://cran.r-project.org/src/base/R-2/R-2.11.1.tar.gz
tar xvf R-2.11.1.tar.gz
Load gcc and java environment environment modules (or set manually, you mad bastard - install modules, dammit!). Change into the directory and configure, make and make install. Note that our configure script is designed to automatically install with an appropriate prefix and for shibboleth if you're using that. i.e.,
module load gcc
module load java
../config.gcc
make
make install
What's in config.gcc
?
#!/bin/bash install=$(basename $(pwd) | sed 's%-%/%') ./configure --prefix=/usr/local/$install-gcc --with-lapack --with-blas --enable-R-shlib
Change to the modules directory and modify the environment modules for the new version. e.g.,
cd /usr/local/Modules/modulefiles/R
ln -s .base 2.11.1
The .base
, at least in this case, looks like the following. YMMV.
#%Module1.0#####################################################################
##
## $name modulefile
##
set ver [lrange [split [ module-info name ] / ] 1 1 ]
set name [lrange [split [ module-info name ] / ] 0 0 ]
set loading [module-info mode load]
set desc [join [read [ open "/usr/local/Modules/modulefiles/$name/.desc" ] ] ]
proc ModulesHelp { } {
puts stderr "\tThis module sets the environment for $name v$ver"
}
module-whatis "$desc (v$ver)"
if { $loading && ![ is-loaded java ] } {
module load java
}
prepend-path LD_LIBRARY_PATH /usr/local/$name/$ver/lib64/R/lib/
prepend-path LD_LIBRARY_PATH /usr/local/$name/$ver/lib64/
prepend-path MANPATH /usr/local/$name/$ver/man
prepend-path PATH /usr/local/$name/$ver/bin
setenv R_HOME /usr/local/$name/$ver
Now for the fun part; ensuring that the optional libraries in the previous version are available for users in the new version.
- ls /usr/local/R/2.11.0-gcc/lib64/R/library --width="1" >> library.list
- ls /usr/local/R/2.11.1-gcc/lib64/R/library --width="1" >> library.list
- sort library.list > library.list.1 (just to be neat)
- uniq library.list.1 > library.list.2
- sed -i 's/^/"/' library.list.2
- sed -i 's/$/", /' library.list.2
- perl -pi -e 'tr/[\012\015]//d' library.list.2
- Login to the cluster, module load the new version of R
- chooseCRANmirror() - select Australia of course.
- Install the packages from library.list.2 e.g.,
install.packages(c("abind", "acepack", "AER", "akima", "anchors", "aplpack", "ash", "base", "biglm", "bitops", "boot", "car", "caTools", "chron", "class", "cluster", "coda", "codetools", "coin", "colorspace", "cubature", "DAAG", "datasets", "DBI", "degreenet", "Design", "dynlm", "e1071", "effects", "ellipse", "ergm", "fBasics", "fCalendar", "fEcofin", "flexmix", "foreach", "forecast", "foreign", "Formula", "fracdiff", "fSeries", "fts", "ftsa", "fUtilities", "gdata", "gee", "gplots", "graphics", "grDevices", "grid", "gtools", "hdrcde", "hexbin", "Hmisc", "HSAUR", "ineq", "ipred", "iterators", "its", "kernlab", "KernSmooth", "kinship", "ks", "latentnet", "lattice", "leaps", "lme4", "lmtest", "locfit", "logspline", "MASS", "Matrix", "maxLik", "mboost", "mclust", "MCMCpack", "MEMSS", "methods", "mgcv", "mice", "mitools", "mix", "mlbench", "mlmRev", "mlogit", "modeltools", "multcomp", "multicore", "mvtnorm", "network", "nlme", "nnet", "numDeriv", "nws", "oz", "party", "pcaPP", "plm", "pscl", "quadprog", "quantreg", "rainbow", "randomForest", "Rcmdr", "RColorBrewer", "R.css", "relimp", "rgenoud", "rgl", "Rglpk", "rlecuyer", "rmeta", "robustbase", "ROCR", "rpart", "RSQLite", "RUnit", "sampleSelection", "sandwich", "scatterplot3d", "sem", "sgeostat", "shapes", "slam", "sna", "snow", "SparseM", "spatial", "splines", "statmod", "statnet", "stats", "stats4", "strucchange", "subselect", "survey", "survival", "systemfit", "TeachingDemos", "timeDate", "timeSeries", "tis", "tkrplot", "tools", "tree", "tripack", "tseries", "tweedie", "urca", "utils", "vcd", "VGAM", "xtable", "xts", "Zelig", "zoo"))
- Exit with quit()
- Go back to /usr/local/Modules/modulefiles/R and change .version
- Modify on the NCI database.
Isn't that pretty?
Make sure that you remove tcltk2 or tcltk from the above.
If new packages are desired, follow the instructions given at the R installation page. The general rule is R CMD INSTALL -l /path/to/library pkg1 pkg2 ...
from the Linux command line or install.packages(c("pkg1", "pkg2"))
from the R command-line.
Note for the tcltk2 package (tcltk has been deprecated), you will need to log out and then login again using the -X option in ssh using the R CMD on the tarball. The install will fail because it cannot reference tk and will hang. Remove the lockfile that results (rm -rf 00LOCK-tcltk2/
), download the tarball, and install (R CMD INSTALL tcltk2_1.1-5.tar.gz