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

brucezepplin
  • 9,202
  • 26
  • 76
  • 129

6 Answers6

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.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
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
janos
  • 120,954
  • 29
  • 226
  • 236
  • 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 '15 at 07: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. – Rich Bianco Sep 12 '16 at 00: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.

Harwant Pannu
  • 91
  • 1
  • 1
  • 1
    This appeared to work, but R still works in console despite none of those packages existing. – Kyouma Jan 11 '20 at 02: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 '22 at 09: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

Abhishek R
  • 4,087
  • 1
  • 17
  • 21