Open In App

How to Install Multiple R Packages?

Last Updated : 13 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will see how to install multiple packages in R Programming Language. Installation can be done in two ways.

Method 1: Installation using application options

Step 1: Open R Studio

Step 2: Navigate to Tools and select the Install packages option 

Step 3: In the Text box packages, enter the package names.

                   

Step 4: Click on install button

Step 5: Find the console after clicking on the install button. If all packages installed successfully the below output will be generated. Otherwise, follow the steps again.

Method 2: Using command

In this method simply specify the packages to be installed as a vector to install.packages() function.

Syntax:

install.packages(c(“package1″,….,”package n”))

Example

R




install.packages(c("ggplot2","dplyr"))


Loading multiple packages 

To load multiple packages at once specify the names of the packages to be loaded to lapply() function.

Syntax:

lapply(c(“package 1″,…”package n”), require, character.only = TRUE)

Example:

R




lapply(c("dplyr", "ggplot2"), require, character.only = TRUE)



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads