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.


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.


Subscribe to the Statistics Globe Newsletter

Get regular updates on the latest tutorials, offers & news at Statistics Globe.
I hate spam & you may opt out anytime: Privacy Policy.

8 Comments. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.