Uninstall or Remove Package from R Environment

How to uninstall or remove package(s) from the R environment? Packages are the fundamental units of R code that help to extend the R language capability. These packages are created by R’s active user community and there are hundreds of packages already created for us to use, you can find these at CRAN. When you install R packages, these are stored under a directory called “library” in the R environment.

Sometimes you would like to remove or uninstall the packages from the R environment. You may be required to clean up the R environment by removing all packages or uninstall the existing version of the package and install it again with the newer version e.t.c

1. Remove Package from R Environment

From the R terminal enter the command remove.packages("package-to-remove") to remove or uninstall the package from R environment.

# Remove Package

Running the above command from the R terminal, you should see something like the below.

r remove package
R Terminal

If you try to load the removed package you will get an error.

> library('dplyr')
Error in library("dplyr") : there is no package called ‘dplyr’

2. Remove R Package from RStudio

If you are using RStudio you can remove or uninstall the package from the packages tab, from the packages tab selected the package you wanted to remove, and click on the X mark on the right side of the selected package. If you don’t have RStudio installed as this is most convenient to write R programs in R programming.

r uninstall package
R Packages in RStudio

3. Conclusion

In this article, you have learned how to remove packages in R by using the R terminal and from RStudio.

Naveen (NNK)

I am Naveen (NNK) working as a Principal Engineer. I am a seasoned Apache Spark Engineer with a passion for harnessing the power of big data and distributed computing to drive innovation and deliver data-driven insights. I love to design, optimize, and managing Apache Spark-based solutions that transform raw data into actionable intelligence. I am also passion about sharing my knowledge in Apache Spark, Hive, PySpark, R etc.

Leave a Reply

You are currently viewing Uninstall or Remove Package from R Environment