Best way to install R on Ubuntu 20.04? - r

Does anyone have a good approach to installing R on Ubuntu 20.04? I can't seem to find a solution for this specific to 20.04 focal through apt.
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
Edit: after going through the link here and adding the entry to sources.list, I ran into issues with dependencies:
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.2-1.2004.0) but it is not going to be installed
Depends: r-recommended (= 4.0.2-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.
Per #DirkEddelbuettel's comment, I ran sudo apt install r-base-core r-recommended r-base-html to see next level dependencies:
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-core : Depends: libblas3 but it is not installable or
libblas.so.3 but it is not installable
Depends: liblapack3 but it is not installable or
liblapack.so.3 but it is not installable
Depends: libtcl8.6 (>= 8.6.0) but it is not installable
Depends: libtk8.6 (>= 8.6.0) but it is not installable
Recommends: r-base-dev but it is not going to be installed
Recommends: r-doc-html but it is not going to be installed
r-recommended : Depends: r-cran-kernsmooth (>= 2.2.14) but it is not going to be installed
Depends: r-cran-mgcv (>= 1.1.5) but it is not going to be installed
Depends: r-cran-rpart (>= 3.1.20) but it is not going to be installed
Depends: r-cran-survival (>= 2.13.2-1) but it is not going to be installed
Depends: r-cran-matrix but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
There was a more underlying issue when I worked on trying to install r-base. I ended up finding out that I had problems with unmet dependencies after adding a PPA. I used this link here to fix the underlying problem of unmet dependencies, which in turn allowed me to apt install and not have any issues installing.

Here is what I do in the Rocker container r-ubuntu for the 20.04 image:
Install software-properties-common to be able to say add-apt-repository
Add the rrutter4.0 PPA for R itself (same as CRAN)
add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0"
Add the c4d4u.teams repo for over 4k CRAN packages:
add-apt-repository --enable-source --yes "ppa:c2d4u.team/c2d4u4.0+"
Run apt install r-base (and a few more).
In a narrow sense you only need 2 (as you likely do not 1 on a full Ubuntu system) and 4 but you may as well do 3.
You can of course also just to docker pull rocker/r-ubuntu:20.04 and get that container pre-made, but I use both: a container for tests, and these settings on my 20.04 machine(s).

Prerequisites
You will need an Ubuntu 20.04 with:
at least 1GB of RAM
a root user / non-root user with sudo privileges
Installing R
Because R is a fast-moving project, the latest stable version isn’t always available from Ubuntu’s repositories, so we’ll start by adding the external repository maintained by CRAN.
Note: CRAN maintains the repositories within their network, but not all external repositories are reliable. Be sure to install only from trusted sources.
Let’s first add the relevant GPG key.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Note that if you’re not using 20.04, you can find the relevant repository from the R Project Ubuntu list, named for each release. Ubuntu 20.04 is referred to as Focal Fossa, and the most recent version of R is 4.0.0, hence the naming convention of the repository below — focal-cran40.
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
Now, we’ll need to run update after this in order to include package manifests from the new repository.
sudo apt update
At this point, we’re ready to install R with the following command.
sudo apt install r-base
If prompted to confirm installation, press y to continue.
Finally get into R shell-
sudo -i R
This confirms that we’ve successfully installed R and entered its interactive shell.

Related

Unable to install latest R version on Ubuntu 18.04 linux

I want to be able to install the latest stable R release for Ubuntu 18.04, I had the ubuntu version installed and so I removed it and then followed several guides like in this link.
No matter what I do I get the following output when I issue a sudo apt-get install r-base:
sudo apt 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 (>= 3.6.1-3disco) but it is not going to be installed
Depends: r-recommended (= 3.6.1-3disco) 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.
What's wrong?

How to install R on ubuntu 16.10 via the terminal?

I'm trying to install R from the terminal following this site:
https://www.r-bloggers.com/how-to-install-r-on-linux-ubuntu-16-04-xenial-xerus/
When I execute sudo apt-get install r-base, I get the following error:
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 (>= 3.3.2-1xenial0) but it is not going to be installed
Depends: r-recommended (= 3.3.2-1xenial0) 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.
Add the two others to the command, and see the errors it generates, ie do
sudo apt-get install r-base r-base-core r-recommended
You likely you have something installed which conflicts. Many (and I mean thousands) of us run these packages just fine.
You can also consider the r-sig-debian mailing list.

Errors when trying to install qtbase5-dev in Ubuntu

I'm trying to install the qt5 development libraries using sudo apt-get install qtbase5-dev, but I'm getting an error:
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:
qtbase5-dev : Depends: libgles2-mesa-dev or
libgles2-dev but it is not installable
Depends: libqt5gui5 (= 5.2.1+dfsg-1ubuntu14.3) but it is not going to be installed
Depends: libqt5printsupport5 (= 5.2.1+dfsg-1ubuntu14.3) but it is not going to be installed
Depends: libqt5widgets5 (= 5.2.1+dfsg-1ubuntu14.3) but it is not going to be installed
Recommends: libqt5opengl5-dev (= 5.2.1+dfsg-1ubuntu14.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
The problem is I don't have held packages - I checked using dpkg --get-selections | grep hold, but it showed nothing.
For me, this was caused by the oibaf graphics PPA being installed.
sudo apt-get install ppa-purge
sudo ppa-purge ppa:oibaf/graphics-drivers
will revert to stock graphics libs.
Manually installing libgles2-mesa-dev and then qtbase5-dev worked. I had to ran it in separate commands though:
sudo apt-get install libgles2-mesa-dev
sudo apt-get install qtbase5-dev

How to install GTK+ in Elementary OS Freya

I'm trying to install the GTK+ library on my distribution using :
sudo apt-get install libgtk-3-dev
However I get these logs (errors):
The following packages have unmet dependencies:
libgtk-3-dev : Depends: libgtk-3-0 (= 3.10.8-0ubuntu1.6) but 3.14.15-0ubuntu1~14.04~ricotz1 is to be installed
Depends: gir1.2-gtk-3.0 (= 3.10.8-0ubuntu1.6) but 3.14.15-0ubuntu1~14.04~ricotz1 is to be installed
Depends: libglib2.0-dev (>= 2.37.5) but it is not going to be installed
Depends: libgdk-pixbuf2.0-dev (>= 2.27.1) but it is not going to be installed
Depends: libpango1.0-dev (>= 1.32.4) but it is not going to be installed
Depends: libatk1.0-dev (>= 2.7.5) but it is not going to be installed
Depends: libatk-bridge2.0-dev but it is not going to be installed
Depends: libcairo2-dev (>= 1.13.0~20140204) but it is not going to be installed
Depends: libwayland-dev (>= 1.2.0) but it is not going to be installed
Depends: libxkbcommon-dev but it is not going to be installed
Depends: libxi-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I've recently started working on unix systems, so I don't know how to correct this.
Any help will be appreciated.
After some serious googling and reading through all the errors , I have discovered that this is a delicate situation . Apparently there is no single answer for this , and if it is it's not the right one.
I've tried the following which works :
It is recommended to use aptitude for this kind of work because aptitude offers a conflict resolver , it basically visualize unmet dependencies (and tries to solve them).
sudo apt-get update
sudo apt-get install aptitude
Then
sudo aptitude install libgtk-3-dev
Even if this will solve the issue in most cases, it does not have a 100% succes rate.
There are differrent approaches , like cleaning up the apt cache , (it didn't work for me) and then using : sudo apt-get install libgtk-3-dev -f , which will attempt to fix broken dependencies.
There are too many ways , all that I have learned is from this post.
NOTE ->
It is possible that I have this particular issue because of my linux distro , I have read that is not very stable and it is recommended to start with some more stable and reliable versions like : Debian or Ubuntu.(for beginners)

Issues in installing r-base-dev

I am currently using Ubuntu 12.04 64 bit .I was trying to install R as specified on this link . I am successfully able to install r-base but getting errors when trying to install r-base-dev . Here is the error
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-dev : Depends: gfortran but it is not installable
Depends: libblas-dev but it is not installable or
libatlas-base-dev but it is not going to be installed
Depends: liblapack-dev but it is not installable or
libatlas-base-dev but it is not going to be installed
Depends: libreadline-dev but it is not installable
Depends: libjpeg-dev but it is not installable
Depends: libpcre3-dev but it is not installable
Depends: libpng-dev but it is not installable
Depends: libbz2-dev but it is not installable
Depends: cdbs but it is not installable
E: Unable to correct problems, you have held broken packages.
I have added the security key as stated in that link as well as the following line deb http://cran.r-project.org/bin/linux/ubuntu precise/ to /etc/apt/sources.list
I have also added the following ppa : sudo add-apt-repository ppa:marutter/rrutter .
Any help would be appreciable.
PS: I was also doubtful with my lists in /var/lib/apt/lists so I deleted and created it again. Still having the same error .
I made sure that the restricted and universe repositories are enabled (which was disabled in case of mine ). For doing this , Hit Alt + F2 type software-properties-gtk and hit Enter.
Under Ubuntu Software tab enable all the repositories.
After which run
sudo apt-get update
Again run
sudo apt-get install r-base-dev
And done successfully.
I got the above solution from this link

Resources