Unable to Install R base in Ubuntu 16.04 - r

I know this was already asked before but none of the answers I tried worked for me. I need to install R but every time I try this error comes up:
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.4.1-2xenial0) but it is not going to be installed
Depends: r-recommended (= 3.4.1-2xenial0) 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.
To other errors that I encountered, I used the ff and solved them:
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo add-apt-repository ppa:marutter/rrutter
sudo apt-get update
sudo apt-get upgrade
However the first error still shows up. Any idea how to solve this? Please.

#neilfws comment was the only thing that helped. I followed his link. And I used this answer (the most upvoted one as of now).
So what I did,
sudo apt-get install aptitude
sudo aptitude install r-base
This first gave me an option to accept but somehow still had some dependencies unresolved, so I rejected the first suggestion and accepted the next one that "sounded reasonable"
Keep the following packages at their current version:
1) r-base [Not Installed]
2) r-cran-foreign [Not Installed]
3) r-recommended [Not Installed]
Leave the following dependencies unresolved:
4) r-base-core recommends r-recommended
Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:
Install the following packages:
1) r-cran-foreign [0.8.69-1xenial0 (xenial)]
Accept this solution? [Y/n/q/?] Y
I have documented the whole re-installation here.
Background
I installed R3.5 on my Ubuntu 16.04, after installing the package XLSX following various resources as documented here, I thought I have problems with other packages (I was wrong), which is when I decided to reinstall. I started with purging all the installations but nothing was enough and I got a similar error as that of the OP.

Related

Best way to install R on Ubuntu 20.04?

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.

Having difficulty with re-installing R in Ubuntu 18.04

Very recently I shifted to Ubuntu from Windows and downloaded R-base (3.4.4) and R studio. However, some packages (car, ROCR etc) were not available and hence I tried to update R. Because of error messages, I finally tried to uninstall and remove R and then install it again.
I tried
sudo apt-get upgrade
sudo apt install r-base
However, it is showing me error message like,
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-recommended (= 3.6.2.20200221-1~ubuntu18.04.1~ppa1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
So basically right now, I have no R-base installed.
I tried to remove R-base.
sudo apt-get remove r-base
And all I am getting is-
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'r-base' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I am a beginner in both R and Linux. I need your valuable suggestions.
Thanks in advance.
If you are using Ubuntu 18.04, please follow these steps if you are using your local machine of your own. (If your are working in any office environment please setup proxy and follow these steps)
1) Let’s first add the relevant GPG key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
2) Add the R Repository
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/'
3) Update Package Lists
sudo apt update
4) Install R
sudo apt install r-base
5) Test Install
sudo -i R
6) Installing R Packages from CRAN
install.packages('dplyr')

Can't install r-base on Ubuntu 19.10; unmet dependencies r-recommended

In general, I am new in working with Ubuntu (19.10;eoan) and currently trying to install r-base. r-base-dev is installed.
When I do so, I get the following message:
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-recommended (= 3.6.2-1xenial) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I have used the following Threads to try to fix my problem - without any succes.
Installing r-base; Depenency: r-recommended missing?
Issues in installing r-base-dev
For this one I stopped at the section: "Disable/Remove/Purge PPA:". Because I was not able to understand the process.
https://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-after-adding-a-ppa
I will appreciate any solution or advice to solve my problem.
Without more information about what you actually tried (and the order) it is difficult to try and pinpoint why it doesn't work, but I recently installed this on 19.10 myself. I used the following.
# Get the key from the keyserver.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
# Add the repository to your sources.list. Make sure that it does not already exist
# and that it is not a typo in there. Making a backup of the file before running the
# next line is useful.
echo "deb https://cloud.r-project.org/bin/linux/ubuntu eoan-cran35/" | sudo tee -a /etc/apt/sources.list
# Install base, dev and other dependencies.
sudo apt install r-base r-base-dev r-cran-curl r-cran-openssl r-cran-xml2 libssl-dev libxml2-dev libcurl4-openssl-dev
It worked without any problem for me. It is very important that you add the correct repository to your sources.list. Judging by the error message you are using a repository referring to Ubuntu Xenial and not Ubuntu Eoan.

readr package not installing on Ubuntu

Hello I am trying to install reader onto my Ubuntu VPS. I only have 1 GB of RAM which is why I can not install it. I came across Dirk's post R (Ubuntu) - Can't install packages "readr" and "eurostat" where he explained the work around.
apt-get update # refresh
apt-get install software-properties-common
add-apt-repository -y "ppa:marutter/rrutter"
add-apt-repository -y "ppa:marutter/c2d4u"
apt-get update # now with new repos
apt-get install r-cran-readr
However, when I run the code. The final line gives me this 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:
r-cran-readr : Depends: r-api-3.4
Depends: r-cran-rcpp but it is not going to be installed
Depends: r-cran-tibble but it is not going to be installed
Depends: r-cran-hms but it is not going to be installed
Depends: r-cran-r6 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I was able to install all the packages separately and tried running the code again. I got the same error. I am not to sure what my next steps should be.
Edit**
I am trying to follow Dirk's advice in the comment section. I am having a difficult time understanding what to do with the "deb" file. Once I have the deb link
deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/
Some sources to me to run the command
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
However, I recieve this error.
keyserver receive failed: No dirmngr
It seems like I have to add the deb link to a directory. I am brand new to Ubuntu and the shell. If someone could explain this to me in simple terms that would be greatly appreciated.

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.

Resources