5

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?

YJZ
  • 3,934
  • 11
  • 43
  • 67
  • What is your `.libPaths()`? – Hong Ooi Jun 21 '17 at 16:21
  • thank you@HongOoi see update in OP please – YJZ Jun 21 '17 at 16:24
  • What does `attr(sessionInfo()$otherPkgs$RODBC, "file")` return after you have uninstalled it but then called library? Did the remove work? There was no error about files being in use? – MrFlick Jun 21 '17 at 16:26
  • thank u @MrFlick i tired your code: it does seem to show the package is still there. I guess the removing didn't work. Do you know how to fix please? – YJZ Jun 21 '17 at 16:31
  • You could restart R and try `remove.packages` again. Or just delete the RODBC directory via Explorer. It's just a normal directory, nothing special about it. – Hong Ooi Jun 21 '17 at 17:02

4 Answers4

4

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

sweetmusicality
  • 937
  • 1
  • 10
  • 27
1

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")
Abel Callejo
  • 13,779
  • 10
  • 69
  • 84
0

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.

Enjoyeer
  • 11
  • 1
0

Also had problems with remove.packages so deleting the folders as suggested by @sweetmusicality worked for me:

#e.g. remove packages associated with tidyverse
pkremove <- tools::package_dependencies("tidyverse", db = installed.packages())$tidyverse
lapply(pkremove, function(x) {
  unlink(paste0(.libPaths()[1], "/", x), recursive = TRUE) 
})
user63230
  • 4,095
  • 21
  • 43