按照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 3.6 之前,我按照R Bloggers 帖子中的说明从宇宙中删除了安装的版本:
然而这是不够的。它留下一个文件夹,其中包含本地编译的 R 包。这可能是
r-base
包的一个错误,即使apt purge
是留下资产:因此,要彻底删除旧 R 版本,必须删除此文件夹:
然后是的,可以从 r-project.org 安装更新的版本:
这样就可以像
ggplot2
使用以下install.packages
方法一样安装软件包: