How to Install and Include an R Package

[This article was first published on R Language in Datazar Blog on Medium, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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

ggplot(data=iris,aes(x=Sepal.Length,y=Petal.Length))+geom_point()

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: https://www.datazar.com/file/f105230b5-0a2f-4976-af08-db1b00f793a4


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.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)