Open In App

Manage packages in R

Last Updated : 28 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will see how to manage packages in R Programming Language using R script.

What are R packages?

R packages are the set of functions and datasets written in a single code and are stored in a directory called library. 

We will be looking at:

  • How to Install packages
  • How to Uninstall packages
  • How to Update packages
  • How to find all the installed packages

Using R pre-defined functions.

How to Install packages:

To install the package in R use install.packages(“packagename”) and replace packagename by the package you want to install.

Syntax:

install.packages(“packagename”)

Note: packagename is case-sensitive.

R




install.packages("httr")


Output:

 

How to Uninstall packages:

To uninstall/remove the package from your device use remove.package(“packagename”) and replace the package name by the package you want to uninstall/remove. This function will remove the package if it is already installed.

Syntax:

remove.packages(“packagename”)

R




remove.packages("httr")


Output:

 

How to Update packages:

To update the package we use update.package() and it does not require any parameters. This function will update all the packages running on the older version.

Syntax:

update.packages()

R




update.packages()


Output:

 

How to find all the installed packages:

To get the installed packages on the device we use installed.packages() and it does not need any parameters as well. This function will show all the installed packages on the device.

Syntax:

installed.packages()

installed.packages() will return all the installed functions on the system.

R




installed.packages()


Output:

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads