R Warning: cannot remove prior installation of Package ‘X’
In this R post you’ll learn how to deal with the warning: cannot remove prior installation of package.
The page looks as follows:
Let’s dive right in…
Fixing the Warning Message: cannot remove prior installation of package ‘X’
Depending on how you previously have installed your R add-on packages, the R programming language might have problems to remove an old package and re-install it properly.
Fortunately, there is an easy fix available. Follow these steps to get rid of the warning message “cannot remove prior installation of package”:
Step 1) Find the directory path where your packages are installed:
.libPaths() # Get paths of installed packages
Step 2) Manually remove all old installations of the package you want to re-install.
Step 3) Install the package in R using the install.packages function:
install.packages("your_package_name") # Install package again
Step 4) Load the package in R using the library function:
library("your_package_name") # Load package
After these steps, your package should work properly.
Video & Further Resources
In case you need further information on the R programming codes of this tutorial, you might have a look at the following video of my YouTube channel. I illustrate the R code of this tutorial in the video:
The YouTube video will be added soon.
Furthermore, you could read some of the related tutorials on this website. You can find some articles below.
- Introduction to the pacman Package in R
- Dealing with Warning & Error Messages in R
- Introduction to R Programming
At this point you should know how to handle the warning message: cannot remove prior installation of package in the R programming language. Don’t hesitate to let me know in the comments section below, if you have additional questions and/or comments.