Install Package In R


This document shows you the steps to install R packages locally without root access on OSC's Oakley cluster. R comes with a single library $R_HOME/library which contains the standard and recommended packages. This is usually in a system location. On Oakley cluster, it is /usr/local/R/3.0.1/lib64/R/library.
A package is a collection of functions & sample data. There are multiple ways top install R Packages & here we will focus on most commonly used techniques.
R also has a default value for a directory where users can install their own R packages. On Oakley cluster, it is ~/R/x86_64-unknown-linux-gnu-library/3.0 if the default R-3.0.1 module is loaded. This directory doesn't exist by default. The first time a user installs an R package, R will ask the user if s/he wants to use the default location and if yes, will create the directory. A Simple Example First you need to load the module for R: module load R On Oakley, the default R module is version 3.0.1. Then fire up an R session: R To install package lattice, use this command inside R: >install.packages('lattice', repos='It gives a warning: Warning in install.packages('lattice'): 'lib = '/usr/local/R/3.0.1/lib64/R/library' is not writable Would you like to create a personal library ~/R/x86_64-unknown-linux-gnu-library/3.0 to install packages into?
(y/n) Answer y, and it will create the directory and install the package there. Setting the Local R Library Path If you want to use another location rather than the default location, for example, ~/local/R_libs/, you need to create the directory first: mkdir ~/local/R_libs Then type the following command inside R: >install.packages('lattice', repos='lib='~/local/R_libs/') It is a bit of burden having to type the long string of library path every time. To avoid doing that, you can create a file.Renviron in your home directory, and add the following line to the file: export R_LIBS=~/local/R_libs/ Whenever R is started, the directory ~/local/R_libs/ is added to the list of places to look for R packages and so: >install.packages('lattice', repos='will have the same effect as the previous install.packages() command. To see the directories where R searches for libraries, use the command:.libPaths(); Setting The Repository When you install an R package, you are asked which repository R should use. To set the repository and avoid having to specify this at every package install, create a file.Rprofile in your home directory.
This is the start up code for R. Add the following line to the file: cat('.Rprofile: Setting R repository:') repo = getOption('repos') # set up the server from which you will download the package. Repo['CRAN'] = 'options(repos = repo) rm(repo) Now you only need to do >install. Samsung Refrigerator Popping Noise more. packages('lattice') That will download the package lattice from and install it in ~/local/R_libs. Updating Packages >Download D Day For Android here. update.packages() inside an R session is the simplest way to ensure that all the packages in your local R library are up to date. It downloads the list of available packages and their current versions, compares it with those installed and offers to fetch and install any that have later versions on the repositories. Removing packages >remove.packages('lattice') inside an R session to remove package lattice. An even easier way is just to go into the directory ~/local/R_libs and remove the directory lattice from there.
References Add-on packages in R installation guide ().
R packages are a collection of R functions, complied code and sample data. They are stored under a directory called 'library' in the R environment. By default, R installs a set of packages during installation. More packages are added later, when they are needed for some specific purpose. When we start the R console, only the default packages are available by default. Other packages which are already installed have to be loaded explicitly to be used by the R program that is going to use them. All the packages available in R language are listed at Below is a list of commands to be used to check, verify and use the R packages.