R: Cannot install rJava; what is r-api-3.4?

DaniCee picture DaniCee · Jul 10, 2018 · Viewed 8.6k times · Source

I am on an Ubuntu 18.04 machine with R version 3.5.1, installed following this link. I am trying to install the CRAN package rJava, which I do the following way (as seen here):

sudo apt-get install r-cran-rjava

However, I get this:

The following packages have unmet dependencies:
 r-cran-rjava : Depends: r-api-3.4
E: Unable to correct problems, you have held broken packages.

But when I try:

sudo apt-get install r-api-3.4

I get:

E: Package 'r-api-3.4' has no installation candidate

How to overcome this problem with r-api-3.4? Basically, I need to install rJava to be able to install and use XLConnect... In Ubuntu 16.04, I had no problems whatsoever...

EDIT:

Apparently, r-api-3.4 should be provided by r-base-core. I do have r-base-core installed in its newest version, why do I still see errors then?

Answer

Ralf Stubner picture Ralf Stubner · Jul 10, 2018

The API versions are provided by r-base-core. The reason is that binary packages (sometimes) depend on the R version, for which they have been build. This way you can only install packages that fit together.

In your case you have packages from the main Ubuntu repository (r-base-core 3.4.x providing r-api-3.4 and r-cran-rjava requiring r-api-3.4) and from a custom PPA (r-base-core 3.5.y providing r-api-3.5). One option would be to only use the version from Ubuntu, i.e. R 3.4. Another solution is to add an additional PPA:

sudo add-apt-repository ppa:marutter/c2d4u3.5
sudo apt-get update

After that a version of r-cran-rjava requiring r-api-3.5 should be available. See also http://rubuntu.netlify.com/post/2018-05-25-announcing-c2d4u3-5/ and http://rubuntu.netlify.com/post/2018-06-11-r-3.5-on-debian-and-ubuntu-update/.

Finally, you always have the possibility to install the R packages directly from CRAN. That is currently the only possibility when you are using the CRAN supplied R backports on Debian.