Breadcrumb
Installing additional R packages on Linux
Installing additional R packages on Linux
On the managed Linux machines in the Statistics department there are a number of add-on packages for R that are managed by the statsoft group. Those packages are in /group/statsoft/Rlibs or /group/statsoft/Rlibs64 depending on the architecture of the machine. If you are logged into a linux machine in the 346 SH lab or a faculty/RA/TA box in SH, your R_LIBS environment variable has been set already to include the statsoft collection.
Most of the information that follows is taken from the R Installation and Administration Managing libraries section.
You can check to see what your R library search path is by starting R and running .libPaths(). An example is shown below:
> .libPaths() [1] "/group/statsoft/Rlibs64" "/usr/lib64/R/library"
Make sure R is NOT running before you start.
- Create a directory in your home directory you would like to install the R packages, e.g.
mkdir ~/Rlibs - Alter your .cshrc or .bashrc to set the R_LIBS environment variable. If you don't know if you need to use .cshrc or .bashrc for your shell, it will likely be .cshrc
For .cshrc:
if ($?R_LIBS) then
setenv R_LIBS ~/Rlibs:$R_LIBS
else
setenv R_LIBS ~/Rlibs
endif
For .bashrc:
if [ -n $R_LIBS ]; then
export R_LIBS=~/Rlibs:$R_LIBS
else
export R_LIBS=~/Rlibs
fi - Run source .cshrc and then start R (bash users should source .bashrc).
- Now when you run .libPaths(), you should see something similar to:
> .libPaths()
[1] "/space/hbrown/Rlibs" "/group/statsoft/Rlibs64"
[3] "/usr/lib64/R/library" - You should now be able to run:
install.packages('packagename',"~/Rlibs","http://streaming.stat.iastate.edu/CRAN")
to install a package (replace 'packagename' with the actual name of the package you want installed). If you leave "packagename" blank, you'll get a list of all available packages.
If you need to add an additional package later, run install.packages( ) from within R to install what you need. You can get more information about the install.packages( ) command by running ?install.packages( )
If you'd like to see which libraries are available in your R library path, run: library()