Open In App

Manage packages in R

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:

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.




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”)




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()




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.




installed.packages()

Output:

 


Article Tags :