Having difficulty with re-installing R in Ubuntu 18.04 - r

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')

Related

Cannot install R - Unable to correct problems, you have held broken packages

We followed instructions here - https://rtask.thinkr.fr/installation-of-r-4-0-on-ubuntu-20-04-lts-and-tips-for-spatial-packages/ - to uninstall R:
sudo apt-get purge r-base* r-recommended r-cran-*
sudo apt autoremove
sudo apt update
...seems to have worked because when we run R in command line we get -bash: /usr/bin/R: No such file or directory. However, when we try to install R using:
apt install --no-install-recommends r-base
...version 3.6.3 is installed, not version 4.0 or 4.1. Here is our machine type.
What can we do to get R version 4.1.0 (preferred) installed on our machine? I am worried that, perhaps it is not possible as if it were, v4 would be the default rather than v3... might it be the case that 16.04 is too old for R v4?
Edit: followed the instructions in the comment below, but ran into the following issue:

Unable to install R 4.0 on Linux Mint 19.1 Tessa

I have been trying for days now. I would like to upgrade to the latest version of R. I have followed advice found on this link :
Problem installing R4.0 on LInux Mint 19.3
but for me the problem persists for me.
When I do
echo -e "\ndeb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/" | sudo tee -a /etc/apt/sources.list
then
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get install r-base
I get this
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 (= 4.0.5-1.1804.0) but it is not going to be installed
W: Target Packages (Packages) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:7
W: Target Translations (en_US) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:7
W: Target Translations (en) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:7
E: Unable to correct problems, you have held broken packages.
If anyone has an idea of how to solve this I would be eternally grateful.
W: Target Translations (en_US) is configured multiple times in /etc/apt/sources.list:5 and /etc/apt/sources.list:7
Remove the duplicate entry in your sources (line 5 and 7):
sudo sed -i '7d' /etc/apt/sources.list
The following packages have unmet dependencies:
r-base : Depends: r-recommended (= 4.0.5-1.1804.0) but it is not going to be installed
Use the following command:
sudo apt update
sudo apt install --no-install-recommends r-base
This post:
https://unix.stackexchange.com/a/612316/367012
Says Mint is different than Ubuntu in adding repositories, and suggests manually editing the repository list,
$ sudo xed /etc/apt/sources.list.d/additional-repositories.list
to add:
deb cloud.r-project.org/bin/linux/ubuntu bionic-cran40/
Save and exit the editor, then update the package list:
$ sudo apt update
This post: https://askubuntu.com/a/1113944/968912 suggests removing all the previous versions of R first.

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.

Unable to Install R base in Ubuntu 16.04

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.

Resources