31

I am trying to update my version of R on linux mint, however broken dependencies are stopping me doing this. after trying everything such as adding repos from Cran, sudo apt-get update, I still cannot install the latest version of R.

MY question is how to i completely remove R from my machine, so that I can restart. I have tried :

sudo apt-get remove r-base

however when I run R it still works:

laptop$ R

R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

and doesn;t seem to be removed at all.

I want a clean, fresh install, but I don't think I am removing R properly

4
  • 1
    Have you seen this in R docs you can uninstall R with make uninstall
    – Pippin
    Dec 2, 2013 at 20:01
  • @Pippin Isn't that only if you built R yourself though?
    – Dason
    Dec 2, 2013 at 20:16
  • 1
    The R binary (well, front-end script) is part of the r-base-core package which contains the core R system. The package r-base just pulls other packages in. Dec 2, 2013 at 20:27
  • dirk can you put this as an answer so i can accept it? Dec 2, 2013 at 21:47

6 Answers 6

35

The R binary (well, front-end script) is part of the r-base-core package which contains the core R system.

The package r-base is a so-called virtual package which exists to just pulls other packages in. Removing it does not remove any parts of the R system --- for which you need to remove r-base-core.

4
  • 2
    How do I remove r-base-core? Sep 23, 2015 at 23:44
  • 1
    I am using Fedora 20 and type sudo yum remove r-base-core, but that returns No Match for argument: r-base-core No Packages marked for removal . Sep 23, 2015 at 23:48
  • @gaelgarcia You are missing the fact that we talking about Debian-based systems here. Sep 24, 2015 at 0:59
  • 13
    sudo apt-get remove r-base-core
    – Bowen Xu
    Jun 27, 2018 at 5:47
19

You might want to check on all currently installed R packages.

You can list all packages whose name starts with "r-" like this:

dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }'

To uninstall all of them, pipe the output to xargs apt-get remove:

dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | xargs apt-get remove --purge
2
  • 4
    The second code line will work only with -y option for the apt-get command: dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | xargs apt-get remove --purge -y
    – Yurié
    Sep 25, 2015 at 7:33
  • 1
    Almost worked - failed because many of the packages ask for "y" to confirm and that caused the sequence to fail. Darn. Was trying to set an alias to r like an old UNIX system I used in the 90s it reran the last command where you specify at least one of the last command characters and specify as many needed for r to know which command to run it was a great time saver. The ! command might have been what it was and I plan to alias r with ! and get what I was used to. -Oh see the commenter above mine explained this. Sep 12, 2016 at 0:46
9
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | sudo xargs apt-get remove --purge -y

Worked for me on Ubuntu 14.04. Note sudo addition to the previous suggestion by others.

2
  • 1
    This appeared to work, but R still works in console despite none of those packages existing.
    – Kyouma
    Jan 11, 2020 at 2:15
  • @Kyouma You probably have still a locally compiled R which can't be found with the solution. You could download the respective tarball from CRAN, untar, configure then make uninstall to get rid of it. Be sure to also delete all packages folders, otherwise there might be trouble. Save package-names as character vector in an .rds and use it in install.packages(package-names) later.
    – jay.sf
    Jul 14, 2022 at 9:30
6

At your Linux command line, try:

dpkg --get-selections | grep "^r\-"

This will list R packages installed on your system. You can then delete them by name.

6

Hopefully this proves useful. In addition to running: sudo apt-get remove r-base sudo apt-get remove r-base-core try also: sudo apt purge r-*

1

The following does the job especially if you want to update your R version.

sudo apt-get remove r-base-core

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.