'can't uninstall packages
Hi I uninstalled a package but it still look accessible, can somebody help please? Thank u!
> remove.packages("RODBC")
Removing package from ‘E:/R/R-3.3.3/library’
(as ‘lib’ is unspecified)
> library(RODBC)
# no error. it's still there
> attr(sessionInfo()$otherPkgs$RODBC, "file")
[1] "E:/R/R-3.3.3/library/RODBC/Meta/package.rds"
# it really is there...
> remove.packages("dplyr")
Removing package from ‘E:/R/R-3.3.3/library’
(as ‘lib’ is unspecified)
> library(dplyr)
Error in library(dplyr) : there is no package called ‘dplyr’
# this guy is removed
> .Library
[1] "E:/R/R-3.3.3/library"
> .libPaths()
[1] "E:/R/R-3.3.3/library"
Would it be possible that the package RODBC
was in use so that can not be removed?
Solution 1:[1]
this has happened to me before and I think what I did was literally go find the package's folder from file explorer on my computer and manually delete it
Solution 2:[2]
I had the same trouble, so I try to delete packages by hand, but found I haven't root authority. Then I close R, and start it with sudo, try to remove packages again. However, it worked for me.
Solution 3:[3]
Possible causes
There could be many reasons as to why it is happening.
In my case, remove.packages("somepackagehere")
was not working because the current system user that I am using doesn't have write
privileges to the packages I want to uninstall. So, this is a possible reason for computers/machines with multiple users using R.
Checking the location of packages
This can be checked by issuing the statement in the R console:
.libPaths()
output
[1] "/Library/Frameworks/R.framework/Versions/4.0/Resources/library"
The directory output may vary per R installation. This is just for my case. The directory output is where the installed packages were stored. It may look different for Windows systems.
Checking privileges
In Mac and Linux, the privileges can be checked by:
cd /Library/Frameworks/R.framework/Versions/4.0/Resources/library
ls -la
output
drwxrwxr-x 422 root admin 13504 Apr 21 19:13 .
drwxrwxr-x 18 root admin 576 Jul 16 2020 ..
drwxr-xr-x 3 mario admin 96 Jun 17 2021 RODBC
drwxr-xr-x 3 mario admin 96 Jun 17 2021 dplyr
In this case, it was mario
who installed the packages. Since I --luigi
-- was currently using the machine, I can not remove those packages. It is only mario
that can do it.
In Windows, I have no clue as to how it can be checked.
Granting privileges
cd /Library/Frameworks/R.framework/Versions/4.0/Resources/library
sudo chown -R luigi:admin .
OR
cd /Library/Frameworks/R.framework/Versions/4.0/Resources/library
sudo chmod -R o+w .
In Windows, I have no clue as to how privileges can be granted.
Removing packages
Finally, with the correct privileges, you can now remove the packages like so:
remove.packages("RODBC")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | sweetmusicality |
Solution 2 | |
Solution 3 | Abel Callejo |