115

I have R 2.12.1 installed in my ubuntu, and I'd like upgrade to lastest version 2.15, how can achieve that ? Thanks

zjffdu
  • 25,496
  • 45
  • 109
  • 159

1 Answers1

236

Since R is already installed, you should be able to upgrade it with this method. First of all, you may want to have the packages you installed in the previous version in the new one,so it is convenient to check this post. Then, follow the instructions from here

  1. Open the sources.list file:

     sudo nano /etc/apt/sources.list    
    
  2. Add a line with the source from where the packages will be retrieved. For example:

     deb https://cloud.r-project.org/bin/linux/ubuntu/ version/
    

    Replace https://cloud.r-project.org with whatever mirror you would like to use, and replace version/ with whatever version of Ubuntu you are using (eg, trusty/, xenial/, and so on). If you're getting a "Malformed line error", check to see if you have a space between /ubuntu/ and version/.

  3. Fetch the secure APT key:

     gpg --keyserver keyserver.ubuntu.com --recv-key E298A3A825C0D65DFD57CBB651716619E084DAB9
    

or

    gpg --hkp://keyserver keyserver.ubuntu.com:80 --recv-key E298A3A825C0D65DFD57CBB651716619E084DAB9
  1. Add it to keyring:

     gpg -a --export E084DAB9 | sudo apt-key add -
    
  2. Update your sources and upgrade your installation:

     sudo apt-get update && sudo apt-get upgrade
    
  3. Install the new version

     sudo apt-get install r-base-dev
    
  4. Recover your old packages following the solution that best suits to you (see this). For instance, to recover all the packages (not only those from CRAN) the idea is:

-- copy the packages from R-oldversion/library to R-newversion/library, (do not overwrite a package if it already exists in the new version!).

-- Run the R command update.packages(checkBuilt=TRUE, ask=FALSE).

Fato39
  • 746
  • 1
  • 11
  • 26
A5C1D2H2I1M1N2O1R2T1
  • 190,393
  • 28
  • 405
  • 485
  • 2
    Hello Ananda and others, I would love to include some of these solutions into the installr package: https://github.com/talgalili/installr/ Are any of you willing to pitch it? – Tal Galili Mar 12 '13 at 11:13
  • 1
    [this](http://askubuntu.com/questions/218708/installing-latest-version-of-r-base) worked – marbel Jun 11 '15 at 04:50
  • sudo su echo "deb http://www.stats.bris.ac.uk/R/bin/linux/ubuntu precise/" >> /etc/apt/sources.list apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 apt-get update apt-get upgrade – Beyhan Gul Feb 17 '16 at 13:16
  • 1
    Note that this method will upgrade many other things besides R, which may not be what you want to do. – Asu Jun 13 '17 at 11:42
  • See my answer for a general way to update `R` on `debian` (on which `Ubuntu` is based): https://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r – dardisco May 31 '19 at 01:20
  • 1
    Hi, just to follow up on that answer. For me, seems that the website from step 2 is down. I used another one : http://cran.rstudio.com/bin/linux/ubuntu/. The line that I added into the source.list file is : **deb http://cran.rstudio.com/bin/linux/ubuntu/ bionic-cran35/** – Mathieu Châteauvert Jun 26 '19 at 18:04
  • 1
    Using the short ID for the key downloaded the spoofed key for me ("Totally Legit Signing Key"). See https://dev.gnupg.org/T4136 for details and update your answer with full key ID. – Fato39 Feb 09 '21 at 13:03
  • @Fato39. Thanks. I've accepted the edit. – A5C1D2H2I1M1N2O1R2T1 Feb 09 '21 at 16:10