What are R Packages?

R Packages are collections of R functions, data, and compiled code. While R comes with a set of packages by default, there are many more packages that can be added to extend the capabilities of R. Whether you're using R to optimize portfolios, analyze genomic sequences, or to predict component failure times, experts in every domain have made resources, applications and code available for free, online.

Browse for packages by name, author, title, and published date or find packages organized by task.


Downloading & Installing CRAN Packages

There are thousands of R packages on CRAN today. You can download and install the add-on packages you want to use.

For CRAN packages, install using install.packages such as:

> install.packages("foreach")


Add-on packages are installed into a directory called the library. To use the package, you can load it into the session using the library("packagename")such as:

> library(foreach)


Creating Your Own R Packages

You can also write your own packages. For help writing a package, read Writing R Extensions.

What are R Task Views?

Task Views are guides on CRAN that group sets of R packages and functions by type of analysis, fields, or methodologies.

You can browse and find packages organized by task view.


Downloading and Installing CRAN Task Views

In order to be able to install task views:

  1. Install the ctv package.

    > install.packages("ctv")
  2. Load the ctv package.

    > library("ctv")
  3. Then, install the CRAN task view of your choice using install.views such as:

    > install.views("Bayesian")