[R Course] How to: Install R Packages

A Beginner’s Guide

Thierry Warin https://warin.ca/aboutme.html (HEC Montréal and CIRANO (Canada))https://www.hec.ca/en/profs/thierry.warin.html

Nüance-R provides this course for you to understand the difference between a package and a library, as well as show you how to install a package. Take a look at this course!


Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages. Others are available for download and installation. Once installed, they have to be loaded into the session to be used.

Adding Packages

You can expand the types of analyses you do be adding other packages. A complete list of contributed packages is available from CRAN.

CRAN is the official repository, it is a network of ftp and web servers maintained by the R community around the world. The R foundation coordinates it, and for a package to be published here, it needs to pass several tests that ensure the package is following CRAN policies.

What’s The Difference Between A Package And A Library ?

Speaking about the library() function, sometimes there is a confusion between a package and a library, and you can find people calling “libraries” to packages. Please don’t get confused: library() is the command used to load a package, and it refers to the place where the package is contained, usually a folder on your computer, while a package is the collection of functions bundled conveniently.

How to use R packages

Download and install a package (you only need to do this once). In your console, copy paste the function install.packages(). Inside the (), write the name of the package you are using inside quotation marks "", like so

# install.packages("package")

To use the package, invoke the library() command to load it into the current session.

# library(package)

Watch this video for a concrete example on how to install a package

Our packages

Nüance-R has created two packages available on CRAN:


R Packages will save you time — you don’t need to think about the best way to organise a project, you can just follow a template. Organising code in a package makes your life easier because packages come with conventions. Standardised conventions lead to standardised tools — if you buy into R’s package conventions, you get many tools for free. It’s even possible to use packages to structure your data analyses. Hopefully, this blog post helped you understand a bit better what R packages are, why we use them and how to use them.


For attribution, please cite this work as

Warin (2020, March 5). Thierry Warin: [R Course] How to: Install R Packages. Retrieved from https://warin.ca/posts/howto-installrpackages/

BibTeX citation

  author = {Warin, Thierry},
  title = {Thierry Warin: [R Course] How to: Install R Packages},
  url = {https://warin.ca/posts/howto-installrpackages/},
  year = {2020}