You are currently viewing 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. R’s active user community creates these packages 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 ” library ” directory in the R environment.

Sometimes you want 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 the 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.

# Check the dplyr package is exist in R or not
> 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 select the package you want to remove, and click on the X mark on the right side of the selected package. If you don’t have RStudio installed this is the most convenient to write R programs in R programming.

r uninstall package
R Packages in RStudio

3. Conclusion

In this article, you have learned removing packages from the R environment is a straightforward process and can be done using either the R terminal or RStudio. Also learned the remove.packages() function in the R terminal allows you to uninstall a specific package, and attempting to load the removed package afterward will result in an error.

If you are using RStudio, the process is even more convenient. You can remove or uninstall a package directly from the Packages tab by selecting the desired package and clicking on the X mark. This graphical interface in RStudio provides an easy and user-friendly way to manage your R packages.

Naveen Nelamali

Naveen Nelamali (NNK) is a Data Engineer with 20+ years of experience in transforming data into actionable insights. Over the years, He has honed his expertise in designing, implementing, and maintaining data pipelines with frameworks like Apache Spark, PySpark, Pandas, R, Hive and Machine Learning. Naveen journey in the field of data engineering has been a continuous learning, innovation, and a strong commitment to data integrity. In this blog, he shares his experiences with the data as he come across. Follow Naveen @ LinkedIn and Medium