Upgrade R in Ubuntu xenial - r

I am trying to update R in my Ubuntu Xenial machine. When I run:
R --version
the output is
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
I have been checking a lot of post about how to do it. My main steps have been:
Open the source list and add the link
sudo nano /etc/apt/sources.list
deb http://cran.rstudio.com/bin/linux/ubuntu xenial/
(Maybe I am adding the link in the wrong place of the source.list? I don't know, I am new in Ubuntu). After adding the link, I save and exit the source.list. Then my steps have been:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install r-base
Once the process is finished, I run again:
R --version
And the output is still
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
I don't have a lot of experience with Linux yet but based on previous post and their solutions I cannot manage to solve the problem.
By the way, I need to update R since some of the packages I need to use (such as rgdal) are not available under the version I currently have
Thanks for the help
M

See this, as you are already doing you have to use the distribution from CRAN:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get install r-base
The CRAN README probably is the right place to read first.

What you have it pretty good. I would make it
a) use a file, say cran.list inside of /etc/apt/sources.list.d/
b) use https://, ie I have deb https://cloud.r-project.org/bin/linux/ubuntu zesty/ (and that actually points to the same CDN servers as what you have)
c) run apt-get update and then check via apt-cache policy r-base-core
It should show both the newer (at CRAN) and older (from Ubuntu):
edd#bud:~$ apt-cache policy r-base-core
r-base-core:
Installed: 3.4.3-1zesty0
Candidate: 3.4.3-1zesty0
Version table:
*** 3.4.3-1zesty0 500
500 https://cloud.r-project.org/bin/linux/ubuntu zesty/ Packages
100 /var/lib/dpkg/status
3.4.2-2zesty 500
500 https://cloud.r-project.org/bin/linux/ubuntu zesty/ Packages
3.4.2-1zesty1 500
500 https://cloud.r-project.org/bin/linux/ubuntu zesty/ Packages
3.4.1-2zesty0 500
500 https://cloud.r-project.org/bin/linux/ubuntu zesty/ Packages
3.4.1-1zesty0 500
500 https://cloud.r-project.org/bin/linux/ubuntu zesty/ Packages
3.4.0-1zesty 500
500 https://cloud.r-project.org/bin/linux/ubuntu zesty/ Packages
3.3.2-1 500
500 http://us.archive.ubuntu.com/ubuntu zesty/universe amd64 Packages
edd#bud:~$
The three stars show that that is the installed version.
d) Now when you see the desired version available, install the usual way via apt-get install r-base-core. You should get the highest version as expected.

Related

How do I solve a dependency error that prevents me from installing R 4.0 on Ubuntu 18.04?

I'm trying to install R 4.0 on Ubuntu, but get this error:
$ sudo apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
r-base : Depends: r-base-core (>= 4.0.0-1.2004.0) but it is not going to be installed
Depends: r-recommended (= 4.0.0-1.2004.0) but it is not going to be installed
Recommends: r-base-html but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I have run these commands to set up apt to receive R 4.0, as recommended at https://cran.r-project.org/bin/linux/ubuntu/README.html:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
sudo apt-get update
What am I doing wrong, and how can I fix it?
I did have R 3.4 installed on this system before, and removed it with
sudo apt-get remove r-*
sudo apt-get purge r-*
Have I screwed something up by doing that?
The error was, it turned out, entirely mine:
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
added the repo for Ubuntu 20.04. I needed:
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/'

Update R in ubuntu

I'm having some problems to update my R in my ubuntu. When I try I get this message:
sudo apt-get install r-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
r-base : Depends: r-base-core (>= 4.0.0-1.1804.0) but 3.6.3-1eoan is to be installed
Depends: r-recommended (= 4.0.0-1.1804.0) but 3.6.3-1eoan is to be installed
E: Unable to correct problems, you have held broken packages.
When I ran: apt policy r-base i've got this message:
apt policy r-base
r-base:
Installed: 3.6.3-1eoan
Candidate: 4.0.0-1.1804.0
Version table:
4.0.0-1.1804.0 500
500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
*** 3.6.3-1eoan 100
100 /var/lib/dpkg/status
3.6.1-4 500
500 http://br.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages
500 http://br.archive.ubuntu.com/ubuntu eoan/universe i386 Packages
I've already changed my source list puting this inside:
https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/
Does anyone know what do I do to resolve this problem?
Browse to /etc/apt/sources.list and check if you have added the correct repo.
Remove any old CRAN mirror like bionic-cran35.
If you haven't properly added the current CRAN mirror, run these commands:
(you can confirm the GPG key here: https://cran.r-project.org/bin/linux/ubuntu/README.html):
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/"
Then fix remaining problems and update (which might already solve the issue):
sudo apt --fix-broken install
sudo apt autoremove
sudo apt update
sudo apt upgrade
Remove current version of r and dependencies:
sudo apt remove r-base-core
sudo apt remove r-recommended
sudo apt remove r-base
Install the newest r-base:
sudo apt install r-base
To check your success, run this code:
R
version

Unable to update to latest version of R

I am trying to update to R version 3.5.3, by using the R manual. However, when I type this line:
deb https://cloud.r-project.org/bin/linux/ubuntu cosmic-cran35/
I get a return of command not found.
I tried to add it to my source list as previously suggested, but this does not seem to work. I am trying to do this on a linux system
Edit: Thanks #Ralf for correction (see comments)
Append the 'deb' line to your sources.list by opening a terminal and typing:
echo "deb https://cloud.r-project.org/bin/linux/ubuntu cosmic-cran35/" | sudo tee -a /etc/apt/sources.list
Install the R-CRAN GPG key to verify what you're installing:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Update your package list and install with:
sudo apt update
sudo apt install r-base r-base-dev

How to upgrade R version on WSL?

I'm running Ubuntu in Windows Subsystem for Linux, and apt-get update isn't finding the newest versions of r-base. On Ubuntu 16.04, the newest R version it gets is 3.2.3. How do I upgrade to newer versions of R?
It turns out that the version of r-base in the default Ubuntu repository is behind the newest version of r-base from CRAN.
The solution is to add R-CRAN to /etc/apt/sources.list, using the instructions here: https://cran.r-project.org/bin/linux/ubuntu/
sudo sh -c 'echo "deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/" >> /etc/apt/sources.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get update
sudo apt-get install --only-upgrade r-base # This upgrades r-base if it's already installed; otherwise it doesn't install it
As #DirkEddelbuettel said in his comments, this README has helpful information for how you can update your R version in a Windows subsystem for Linux (WSL) setting. For me, I updated from R 3.4 to R 4.0 on Ubuntu 18.04.
I am running bionic (I used lsb_release -a to find out), and I wanted R 4.0 so I picked the appropriate deb line (for me: deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/) to add to my /etc/apt/sources.list file (had to use sudo vim /etc/apt/sources.list to add this line to the end). Then I ran sudo apt-get update and sudo apt-get install r-base. Now I have 4.0.2, the newest version. Just pick the particular Ubuntu/R combo that you want based on the options from the README. I hope this can help someone.

What's the best way to install R packages on Linux?

I happen to have Linux Mint on my machine (and I am not very experienced in Linux). When trying to install R packages (using install.packages()) on Linux Mint, I've got the following problems:
The installation process goes very slowly (the packages are being compiled each time)
Some packages could not be installed due to compilation errors.
So, I wonder, is there any standard approach to install packages for Linux Mint?
The repositories are available in any standard Ubuntu installation via the package manager. To get the latest version try adding cran.rstudio.com repository for Ubuntu:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get install r-base
(Details see R-Project homepage)

Resources