在 Ubuntu 20.04 上安装 R 的最佳方式? [英] Best way to install R on Ubuntu 20.04?

查看:72
本文介绍了在 Ubuntu 20.04 上安装 R 的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有在 Ubuntu 20.04 上安装 R 的好方法?我似乎无法通过 apt 找到针对 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

通过链接这里和将条目添加到 sources.list,我遇到了依赖项问题:

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.

根据@DirkEddelbuettel 的评论,我运行 sudo apt install r-base-core r-recommended r-base-html 以查看下一级依赖项:

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.

当我尝试安装 r-base 时,有一个更根本的问题.我最终发现在添加 PPA 后我遇到了未满足的依赖项问题.我使用了这个链接这里 修复未满足的依赖项的潜在问题,这反过来又使我能够进行 apt 安装并且安装时不会出现任何问题.

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.

推荐答案

这是我在 20.04 镜像的 Rocker 容器 r-ubuntu:

  1. 安装software-properties-common就可以说add-apt-repository

为 R 本身添加 rrutter4.0 PPA(与 CRAN 相同)
add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0"

Add the rrutter4.0 PPA for R itself (same as CRAN)
add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0"

为超过 4k 的 CRAN 包添加 c4d4u.teams 存储库:
add-apt-repository --enable-source --yes ppa:c2d4u.team/c2d4u4.0+"

Add the c4d4u.teams repo for over 4k CRAN packages:
add-apt-repository --enable-source --yes "ppa:c2d4u.team/c2d4u4.0+"

运行 apt install r-base(以及更多).

狭义上,您只需要 2 个(因为在完整的 Ubuntu 系统上您可能不需要 1 个)和 4 个,但您也可以做 3 个.

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.

您当然也可以仅使用 docker pull rocker/r-ubuntu:20.04 并预制该容器,但我同时使用:用于测试的容器,以及我 20.04 上的这些设置机器.

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

这篇关于在 Ubuntu 20.04 上安装 R 的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆