R is basically a programming language, and it comes with a set of libraries, often called packages, preinstalled by default. Those are considered the ‘base’ packages. There are thousands of other packages written for R, and many of them are available from the Comprehensive R Archive Network (CRAN).
R has built-in capability to contact CRAN, download packages from there, and install them quite simply. You install R packages (or libraries or modules) only once from a login node and they are available to load thereafter.
R libraries at CRAN will have a reference manual available. If you go to the CRAN web site,
http://cran.r-project.org/, then follow the link on the left under Software to Packages, there is a
Table of available packages, sorted by name. So, for example, the package
agricolae, has on its package page at CRAN both a reference manual and a vignette, both in
Most R packages will install nicely and without difficulty. It will usually be a matter of running the
install.packages() command with the appropriate package name and making a couple of choices. Most problems arise because of version incompatibilities. In some cases, an older library will have been superceded by a newer package, or it may have changed name for a newer version if substantial changes have been made.
Here is an example using the
pln package for “Polytomous logit-normit (graded logistic) model estimation”. This is a slightly edited transcript of what it looks like to install and then load a package.
$ R R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows" Copyright (C) 2012 The R Foundation for Statistical Computing [ . . . . ] > install.packages("pln") Warning in install.packages("pln") : 'lib = "/home/software/rhel6/R/2.15.1-gcc/lib64/R/library"' is not writable Would you like to use a personal library instead? (y/n) y Would you like to create a personal library ~/R/x86_64-unknown-linux-gnu-library/2.15 to install packages into? (y/n) y --- Please select a CRAN mirror for use in this session --- [ . . . . ] 75: USA (MD) 76: USA (MI) 77: USA (MO) 78: USA (OH) Selection: 76 trying URL 'http://cran.mtu.edu/src/contrib/pln_0.2.tar.gz' Content type 'application/x-gzip' length 88763 bytes (86 Kb) opened URL ================================================== downloaded 86 Kb * installing *source* package 'pln' ... ** package 'pln' successfully unpacked and MD5 sums checked ** libs gcc -std=gnu99 -I/home/software/rhel6/R/2.15.1-gcc/lib64/R/include -DNDEBUG -I/usr/local/include -DR -DALL -fpic -O3 -mtune=native -c amatrix.c -o amatrix.o [ . . . . ] installing to /home/uniqname/R/x86_64-unknown-linux-gnu-library/2.15/pln/libs ** R ** data ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** testing if installed package can be loaded * DONE (pln) The downloaded source packages are in '/tmp/RtmpnCsqcs/downloaded_packages' > library(pln)
A couple of comments on the output above. R warns you that you do not have permission to write to the system library and offers you the opportunity to create a personal library. You do want to do this, and you are generally safe to accept the default location for that, which will be in your home directory under R followed by directories to indicate the type of computer, the R version, and package name. If the library into which you are installing exists, you will not be prompted for this information.
Many of the packages need to be compiled, but that should be all taken care of for you by the R