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.
8 Comments. Leave new
if many packages need to be updated, how to do it? it is spend too much time to find them and delete.
Hey Jie Jie,
You can do this using the pacman package. Please have a look here.
Regards,
Joachim
Thank you! Finally I could update vctrs package!
Hello Stefano,
We are glad that the tutorial helped with your problem!
Regards,
Cansu
Thanks for the post; this issue has been an irritant, to say the least.
Slight correction – the call to `library` should be a name, and if a string is used, we have to set the argument `character.only` to `TRUE`.
Hey Victor,
Thanks a lot for the kind feedback and your suggestion!
I’m uncertain if I get your suggestion correctly, though. As far as I know, it doesn’t make a difference whether you use quotation marks within the library function. Could you maybe provide some code to illustrate your suggestion?
Thanks!
Joachim
Não consigo voltar a reinstalar o pacote? ele corre sem erros mas não me aparece na lista e quando chamo dá erro
Hello Caroline,
Can you please share the code and error?
Best,
Cansu