R:无法安装 rJava;什么是 r-api-3.4?

2022-01-13 00:00:00 r package installation java rjava

我在一台带有 R 版本 3.5.1 的 Ubuntu 18.04 机器上,按照 this 安装链接.我正在尝试安装 CRAN 包 rJava,我按照以下方式进行安装(如 这里):

sudo apt-get install r-cran-rjava

但是,我明白了:

以下包有未满足的依赖关系:r-cran-rjava :取决于:r-api-3.4E: 无法纠正问题,您持有破损的包裹.

但是当我尝试时:

sudo apt-get install r-api-3.4

我明白了:

E: 包 'r-api-3.4' 没有安装候选

如何用 r-api-3.4 解决这个问题?基本上,我需要安装 rJava 才能安装和使用 XLConnect...在 Ubuntu 16.04 中,我没有任何问题...

显然 r-api-3.4 应该由 r-base-core 提供.我确实在其最新版本中安装了 r-base-core,为什么我仍然会看到错误?

解决方案

API版本由r-base-core提供.原因是二进制包(有时)依赖于构建它们的 R 版本.这样,您只能安装组合在一起的软件包.

在您的情况下,您有来自主 Ubuntu 存储库的软件包(r-base-core 3.4.x 提供 r-api-3.4r-cran-rjava 需要 r-api-3.4)和自定义 PPA(r-base-core 3.5.y 提供 r-api-3.5).一种选择是仅使用 Ubuntu 的版本,即 R 3.4.另一种解决方案是添加额外的 PPA:

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

之后应该可以使用需要 r-api-3.5r-cran-rjava 版本.另请参阅 http://rubuntu.netlify.com/post/2018-05-25-announcing-c2d4u3-5/ 和 http://rubuntu.netlify.com/post/2018-06-11-r-3.5-on-debian-and-ubuntu-update/.p>

最后,您始终可以直接从 CRAN 安装 R 包.当您在 Debian 上使用 CRAN 提供的 R backports 时,这是目前唯一的可能性.

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?

解决方案

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.

相关文章