AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1219737
Accepted
Luís de Sousa
Luís de Sousa
Asked: 2020-03-25 01:36:33 +0800 CST2020-03-25 01:36:33 +0800 CST 2020-03-25 01:36:33 +0800 CST

在 Ubuntu 18.04 上为 R 3.6 安装 ggplot2

  • 772

按照R Bloggers的这篇文章中的说明,我从r-project.org 存储库安装了 R 3.6 。现在我想安装软件包,但没有成功。ggplot2

通常我更喜欢将所有东西都安装为用户包,R 那样工作得更好。但是,对于此版本isoband,所依赖的包ggplot2无法编译:

$ sudo R 

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("ggplot2")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependency ‘isoband’

trying URL 'https://cloud.r-project.org/src/contrib/isoband_0.2.0.tar.gz'
Content type 'application/x-gzip' length 1894070 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

trying URL 'https://cloud.r-project.org/src/contrib/ggplot2_3.3.0.tar.gz'
Content type 'application/x-gzip' length 3031461 bytes (2.9 MB)
==================================================
downloaded 2.9 MB

* installing *source* package ‘isoband’ ...
** package ‘isoband’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/testthat/include"   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
In file included from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:79:0,
                 from RcppExports.cpp:4:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/Rmath.h: In function ‘double R::pythag(double, double)’:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/Rmath.h:222:57: error: ‘::Rf_pythag’ has not been declared
     inline double pythag(double a, double b) { return ::Rf_pythag(a, b); }
                                                         ^~~~~~~~~
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/Rmath.h:222:57: note: suggested alternative: ‘pythag’
     inline double pythag(double a, double b) { return ::Rf_pythag(a, b); }
                                                         ^~~~~~~~~
                                                         pythag
/usr/lib/R/etc/Makeconf:177: recipe for target 'RcppExports.o' failed
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘isoband’
* removing ‘/usr/local/lib/R/site-library/isoband’
ERROR: dependency ‘isoband’ is not available for package ‘ggplot2’
* removing ‘/usr/local/lib/R/site-library/ggplot2’

The downloaded source packages are in
    ‘/tmp/RtmpzfegOo/downloaded_packages’
Warning messages:
1: In install.packages("ggplot2") :
  installation of package ‘isoband’ had non-zero exit status
2: In install.packages("ggplot2") :
  installation of package ‘ggplot2’ had non-zero exit status
> 

同一篇R Bloggers 帖子建议使用 Michael Rutter 的 PPA 作为预编译包的来源。但是,此 PPA 似乎正在安装不兼容版本的软件包:

$ sudo add-apt-repository ppa:marutter/c2d4u3.5
[...]

$ sudo apt-get update
[...]

$ R

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library("ggplot2")
Error: package or namespace load failed for ‘ggplot2’:
 package ‘scales’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
> 

ggplot2在 Ubuntu 18.04 上安装 R 3.6会有不同的方式吗?

r 18.04
  • 1 1 个回答
  • 4216 Views

1 个回答

  • Voted
  1. Best Answer
    Luís de Sousa
    2020-03-25T08:25:20+08:002020-03-25T08:25:20+08:00

    在安装 R 3.6 之前,我按照R Bloggers 帖子中的说明从宇宙中删除了安装的版本:

    sudo apt purge r-base r-recommended r-cran-*
    sudo apt autoremove
    sudo apt update
    

    然而这是不够的。它留下一个文件夹,其中包含本地编译的 R 包。这可能是r-base包的一个错误,即使apt purge是留下资产:

    $ ls /usr/local/lib/R/site-library
    assertthat  desc      ggplot2    lifecycle     pkgload      purrr         rprojroot   tidyselect
    backports   digest    glue       lubridate     plogr        R6            rstudioapi  timeDate
    BH          dplyr     gower      magrittr      plyr         ranger        scales      utf8
    callr       ellipsis  gtable     ModelMetrics  praise       RColorBrewer  SQUAREM     vctrs
    caret       evaluate  ipred      munsell       prettyunits  Rcpp          stringi     viridisLite
    cli         fansi     isoband    numDeriv      pROC         RcppEigen     stringr     withr
    colorspace  farver    iterators  pillar        processx     recipes       testthat
    crayon      foreach   labeling   pkgbuild      prodlim      reshape2      tibble
    data.table  generics  lava       pkgconfig     ps           rlang         tidyr
    

    因此,要彻底删除旧 R 版本,必须删除此文件夹:

    sudo rm -Rf /usr/local/lib/R/site-library
    

    然后是的,可以从 r-project.org 安装更新的版本:

    sudo apt install r-base r-base-core r-recommended
    

    这样就可以像ggplot2使用以下install.packages方法一样安装软件包:

    R
    [...]
    > install.packages("ggplot2")
    
    • 4

相关问题

  • 如何在 Kubuntu 中获得 Cantor 的 R 后端?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve