Skip to content
Related Articles

Related Articles

Improve Article

How to Install a Package in R ?

  • Last Updated : 21 Apr, 2021

R programming language doesn’t come with all packages installed, and they need to be installed explicitly. In this article, we will discuss How to Install a Package in the R language.

Installing packages in Rstudio.

Method 1: Using application options

1. Open R studio.

2. Select tools



3. After selecting the tools you need to press install packages.

4. Here you need to give the package name you need to install.

Here we used expm. This function computes the exponential of a square matrix.

Installing packages in RGui:

1. Open RGui

2. Select packages



3. Select install packages.

4. Select required package and click ok.

 Package will be installed 

package 'expm' successfully unpacked and MD5 sums checked

Method 2: Using command 

In this method, simply pass the package to be installed as an argument to install.packages() function

Syntax:

install.packages(“package name”)

Example:

R




install.packages("ggplot2")

Loading a package

A package can be loaded once it has been installed using library() command.

Syntax;

library(“package_name”)

Example:

R




library("ggplot2")
My Personal Notes arrow_drop_up
Recommended Articles
Page :