How to Install an R Package?

Longhai Li, Department of Mathematics and Statistics, University of Saskatchewan

I occacionally publish R add-on packages for others to implement and test the statistical methodoglogies I discuss in my papers. R is a free software environment for statistical computing and graphics, available from http://www.r-project.org. The following is a brief instruction of installing R packages. More details can be found by typing ?INSTALL in R console.

Install a new package to your computer

Method 1: Install from source

Download the add-on R package, say mypkg, and type the following command in Unix console to install it to /my/own/R-packages/:

$ R CMD INSTALL mypkg -l /my/own/R-packages/

Method 2: Install from CRAN directly

Type the following command in R console to install it to /my/own/R-packages/ directly from CRAN:

> install.packages("mypkg", lib="/my/own/R-packages/")

Load the library

Type the following command in R console to load the package

> library("mypkg", lib.loc="/my/own/R-packages/")

Instructions of using R

If you are new to R, you can learn very quickly how to use R, following for example these introductions:
Back to Longhai Li's software packages