Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Ubuntu 20.04上安装R的最佳方式?_R_Ubuntu 20.04 - Fatal编程技术网

在Ubuntu 20.04上安装R的最佳方式?

在Ubuntu 20.04上安装R的最佳方式?,r,ubuntu-20.04,R,Ubuntu 20.04,有没有人有在Ubuntu 20.04上安装R的好方法?我似乎无法通过apt找到针对20.04 focal的解决方案 No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal 编辑:在浏览链接并将条目添加到sources.list后,我遇到了依赖项问题: Reading package lists... Done

有没有人有在Ubuntu 20.04上安装R的好方法?我似乎无法通过apt找到针对20.04 focal的解决方案

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal
编辑:在浏览链接并将条目添加到sources.list后,我遇到了依赖项问题:

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.
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.
根据@DirkEddelbuettel的评论,我运行了sudo apt install r-base-core r-recommended r-base-html以查看下一级依赖项:

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.
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安装,并且在安装时没有任何问题。

以下是我在中所做的:

  • 安装
    software properties common
    以便能够说
    add apt repository

  • 为R本身添加rrutter4.0 PPA(与CRAN相同)
    添加apt存储库--启用源代码--是“ppa:marutter/rrutter4.0”

  • 为超过4k的CRAN包添加c4d4u.TEAM回购:
    添加apt存储库--启用源代码--是“ppa:c2d4u.team/c2d4u4.0+”

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

  • 从狭义上讲,你只需要2个(在一个完整的Ubuntu系统上你可能不需要1个)和4个,但你也可以做3个

    当然,你也可以只需
    docker拉摇杆/r-ubuntu:20.04
    并预先制作容器,但我同时使用:用于测试的容器,以及我的20.04机器上的这些设置。

    您需要一个Ubuntu 20.04,其中包含:

    至少1GB内存 具有sudo权限的root用户/非root用户

    安装R 因为R是一个快速发展的项目,最新的稳定版本并不总是可以从Ubuntu的存储库中获得,所以我们将从添加由CRAN维护的外部存储库开始

    注意:CRAN在其网络内维护存储库,但并非所有外部存储库都是可靠的。请确保仅从受信任的来源安装

    让我们首先添加相关的GPG密钥

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
    
    请注意,如果您没有使用20.04,您可以从R Project Ubuntu列表中找到相关的存储库,该列表为每个版本命名。Ubuntu20.04被称为Focal Fossa,R的最新版本是4.0.0,因此下面存储库的命名约定是Focal-40

    sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
    
    现在,我们需要在此之后运行更新,以便包含来自新存储库的包清单

    sudo apt update
    
    现在,我们准备使用以下命令安装R

    sudo apt install r-base
    
    如果提示确认安装,请按y键继续

    最后进入R壳-

    sudo -i R
    

    这确认我们已成功安装R并进入其交互式shell。

    您尝试了什么命令?通常,
    sudo apt安装r-base r-base-dev
    应该work@HongOoi我尝试通过将条目添加到sources.list来跟踪链接,运行sudo-apt-get-update和sudo-apt-get-install r-base并得到错误
    以下软件包具有未满足的依赖项:r-base:dependens:r-base-core(>=4.0.2-1.2004.0)但它不会被安装取决于:r-推荐(=4.0.2-1.2004.0)但它不会被安装推荐:r-base-html但它不会被安装E:无法纠正问题,您持有的软件包已损坏。
    @duckmayr我也这么认为。它不应该像我想象的那样艰难。无论如何,你现在需要继续。在同一行中添加
    libblas3 liblapack3 libtcl8.6 libtk8.6
    ,看看您得到了什么。这是一致的。某个地方发生了冲突。(我是从一个自几年前建成以来每六个月升级一次的20.04系统输入的。)这正是我想要的。我遇到了apt的另一个问题,它不允许我在PPA之后解决未满足的依赖关系。我修复了这个问题,然后安装了R。我还测试了容器,效果非常好。谢谢。很高兴听到它起作用了。如果在与另一个PPA的互动中有一个普遍的经验教训,可以将其作为编辑添加到问题中?