Установка ggplot2 для R 3.6 на Ubuntu 18.04

Мне установили R 3.6 из репозитория r-project.org, как проинструктировано в этом сообщении от Блоггеров R. Теперь я хотел бы установить 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 предлагает PPA от Michael Rutter как источник предварительно скомпилированных пакетов. Однако этот 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 с R 3.6 на Ubuntu 18.04?

1
задан 24 March 2020 в 12:36

1 ответ

Прежде, чем установить R 3.6 я удалил версию, установленную из вселенной, следуя инструкциям в сообщении Блоггеров R:

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")
1
ответ дан 7 April 2020 в 23:30

Другие вопросы по тегам:

Похожие вопросы: