How to Install and Include an R Package

February 8, 2018

(This article was first published on R Language in Datazar Blog on Medium, and kindly contributed to R-bloggers)

We get a lot of questions about the usage of R libraries. The most common question is “can I use all the R libraries in your notebooks/consoles?”

Yes! You can use any of the libraries that have been published to the R package repository (CRAN).

Open up your notebook/console:

1. Install

install.packages("ggplot2") this will install the package if it hasn’t already been installed.

2. Include

library(ggplot2) this will call/include the library into your session.

3. Use


Remember, when installing packages, you have to use quote marks inside the install.packages("") function but not when including them using the library().

Once libraries are installed, you don’t have to install them again. You can just call them with library() and then use them as you wish.

Link to notebook:

How to Install and Include an R Package was originally published in Datazar Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.

To leave a comment for the author, please follow the link and comment on their blog: R Language in Datazar Blog on Medium. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)