R is a popular, powerful and a free statistical package. In the ABCC, R software (version 2.6.0) is installed in dexter. Dexter is a SGI Altix Itanium-64 system with 128 nodes and 512 GB of RAM. You will need your ABCC username & password to access dexter.
There are two ways to add packages in R. The first one needs administrative privileges and will add packages to the standard R library collection (a directory containing all the standard and administrator added packages). The second one doesn't require root access and can be used to install package(s) in a local library (usually a directory of User's choice). User(s) can add any number of packages and can then add his local library(ies) to the standard R library. In this document, I will explain how you can add R-packages using the second method.
In this document, unix and R commands are shown in red and blue fonts.
ssh tork.ncifcrf.gov
qsub -I -l nodes=dexter,pvmem=4000mb,mem=4000mb
cd mkdir ~/myRlibs
In this exercise, we will be using Intel compilers (C/Fortran) to compile and create library files. Make sure you are pointing to intel compilers (icc and ifort), by typing
whereis icc whereis ifort
If you want you can use GNU compiler collection or G95 for compilation. Please note that not all packages use compilers.
For example, suppose if we are interested in using a package called UsingR. UsingR is a collection of datasets to learn basic statistics. First, we have to find out whether this package is already installed in our R installation. Type
R26to start a new R session.
library()
to list the packages that are available. Use spacebar to scroll through the library listing and type q to come out of the listing. Use q() to come out of the R session. Type n to the question, save workspace image. When we scrolled through the list, we found that UsingR is not part of our R library. In the next few paragraphs, I will explain how you can add packages without super-user privileges.
Make sure you are out of R session, then type the following command:
R26 CMD INSTALL -l myRlibs UsingR_0.1-8.tar.gz
The command INSTALL will install UsingR under myRlibs directory. Do a listing command, ls myRlibs , to make sure that a directory called UsingR exists.
Now, let us see how we can force R to use myRlibs as an additional library location.
R26From within R session, type
.libPaths()(Note: the "." before libPaths).
This should list the standard R-library path
"/usr/local/inst/R-2.6.0/library"Now, type
.libPaths(c("~/myRlibs"))
library(usingR)
(Note: the "." before libPaths.) This should list the standard R-library path and package(s) you had added to your local R-library (ie myRlibs). For example, in my case, when I type library() , I see the following output.
Packages in library '~/myRlibs':
UsingR Data sets for the text "Using R for
Introductory Statistics"
Packages in library '/usr/local/inst/R-2.6.0/library':
.....
....
...
That finishes the exercise on how to create local library containing R-packages. If you want to practice adding one more package to your local collection, click here and download the randomForest(4.5-23) package. randomForest is a classification and regression method based on a forest of trees using random inputs. Run through the instructions one more time to add RandomForest package to your local library.
Finally, you can carry out this procedure in several different ways in R. For instance, you can also set your own library path as a variable in your .cshrc file as follows
setenv R_LIBS ~/myRlibs
This will load your own library each time you start R, and so you can skip step 4.
I would like to thank Dennis Foley, our IBM System Administrator, for working with me closely during the installation of R-2.6.0. Many thanks to Dr. Brian D. Peyser, USAMRIID, for identifying a typo in the document and for his suggestion on using the HOME directory for myRlibs.
Please contact Dennis (foleyd at ncifcrf dot gov) or me if you have any questions about using R in ABCC. Thanks to Bob Lebherz for proof-reading this document; any remaining errors are my own.
S. Ravichandran, Ph.D. Scientist Advanced Biomedical Computing Center Bldg 430, Room 227 National Cancer Institute Frederick, MD 21702 Email: sravi at ncifcrf dot gov Web: http://ncisgi.ncifcrf.gov/~ravichas Voice: 301-846-1991 Fax: 301-846-5762