如何安装最新的 rlang 和 dplyr?

如何安装最新的 rlang 和 dplyr?

我想执行以以下内容开头的脚本

library(dplyr)  
library(lubridate)  
library(ggplot2)  

我从常规版本开始r-base-core,然后r-cran-lubridate安装。我得到了:

Error in mutate_impl(.data, dots) : 
  Evaluation error: `as_dictionary()` is defunct as of rlang 0.3.0.
Please use `as_data_pronoun()` instead.

(代码本身没有使用mutate_impl它似乎是这个问题https://github.com/r-lib/rlang/issues/674,建议更新dplyr

r 版本R version 3.4.4 (2018-03-15)适用于 dplyr 我不知道如何找出。

因此我按照其他地方的描述更改了源:添加deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35//etc/apt/sources.list

sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-cran-dplyr
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-cran-dplyr : Depends: r-api-3.4
                Depends: r-cran-assertthat but it is not going to be installed
                Depends: r-cran-bindrcpp (>= 0.2) but it is not going to be installed
                Depends: r-cran-glue (>= 1.1.1) but it is not going to be installed
                Depends: r-cran-magrittr but it is not going to be installed
                Depends: r-cran-pkgconfig but it is not going to be installed
                Depends: r-cran-rlang (>= 0.1.2) but it is not going to be installed
                Depends: r-cran-r6 but it is not going to be installed
                Depends: r-cran-rcpp (>= 0.12.7) but it is not going to be installed
                Depends: r-cran-tibble (>= 1.3.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我跑了

sudo apt-get remove r-*
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-cran-dplyr

但什么都没改变。
从 R shell 内部安装它也不起作用:

> install.packages("dplyr")
Installing package into ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependencies ‘pillar’, ‘purrr’, ‘bindrcpp’, ‘tibble’, ‘tidyselect’

trying URL 'https://cloud.r-project.org/src/contrib/pillar_1.3.0.tar.gz'...
downloaded 100 KB

trying URL 'https://cloud.r-project.org/src/contrib/purrr_0.2.5.tar.gz'...
downloaded 123 KB

trying URL 'https://cloud.r-project.org/src/contrib/bindrcpp_0.2.2.tar.gz'...
downloaded 10212 bytes

trying URL 'https://cloud.r-project.org/src/contrib/tibble_1.4.2.tar.gz'...
downloaded 107 KB

trying URL 'https://cloud.r-project.org/src/contrib/tidyselect_0.2.5.tar.gz'...
downloaded 21 KB

trying URL 'https://cloud.r-project.org/src/contrib/dplyr_0.7.8.tar.gz'...
downloaded 702 KB

* installing *source* package ‘pillar’ ...
** package ‘pillar’ successfully unpacked and MD5 sums checked
** R
** byte-compile and prepare package for lazy loading
Error : package ‘rlang’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
ERROR: lazy loading failed for package ‘pillar’
* removing ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5/pillar’
* installing *source* package ‘bindrcpp’ ...
** package ‘bindrcpp’ successfully unpacked and MD5 sums checked
** libs
g++  -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I. -I"/home/_/R/x86_64-pc-linux-gnu-library/3.5/plogr/include" -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oUvOgu/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++  -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I. -I"/home/_/R/x86_64-pc-linux-gnu-library/3.5/plogr/include" -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oUvOgu/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c create.cpp -o create.o
g++  -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I. -I"/home/_/R/x86_64-pc-linux-gnu-library/3.5/plogr/include" -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oUvOgu/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c plogr.cpp -o plogr.o
g++  -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I. -I"/home/_/R/x86_64-pc-linux-gnu-library/3.5/plogr/include" -I"/usr/local/lib/R/site-library/Rcpp/include"    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-oUvOgu/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c test.cpp -o test.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o bindrcpp.so RcppExports.o create.o plogr.o test.o -L/usr/lib/R/lib -lR
installing to /home/t/R/x86_64-pc-linux-gnu-library/3.5/bindrcpp/libs
** R
** inst
** byte-compile and prepare package for lazy loading
Error : package ‘Rcpp’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
ERROR: lazy loading failed for package ‘bindrcpp’
* removing ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5/bindrcpp’
ERROR: dependency ‘pillar’ is not available for package ‘tibble’
* removing ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5/tibble’
ERROR: dependency ‘tibble’ is not available for package ‘purrr’
* removing ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5/purrr’
ERROR: dependency ‘purrr’ is not available for package ‘tidyselect’
* removing ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5/tidyselect’
ERROR: dependencies ‘bindrcpp’, ‘tibble’, ‘tidyselect’ are not available for package ‘dplyr’
* removing ‘/home/_/R/x86_64-pc-linux-gnu-library/3.5/dplyr’

The downloaded source packages are in
    ‘/tmp/Rtmpxim56P/downloaded_packages’
Warning messages:
1: In install.packages("dplyr") :
  installation of package ‘pillar’ had non-zero exit status
2: In install.packages("dplyr") :
  installation of package ‘bindrcpp’ had non-zero exit status
3: In install.packages("dplyr") :
  installation of package ‘tibble’ had non-zero exit status
4: In install.packages("dplyr") :
  installation of package ‘purrr’ had non-zero exit status
5: In install.packages("dplyr") :
  installation of package ‘tidyselect’ had non-zero exit status
6: In install.packages("dplyr") :
  installation of package ‘dplyr’ had non-zero exit status
> 

答案1

我也无法安装dplyr在 Ubuntu 18.04 中。我的 R 版本是 3.6.1,这似乎导致了这个问题。

我跟着此解决方案并做了以下事情

sudo add-apt-repository ppa:marutter/c2d4u3.5
sudo apt update
sudo apt install r-cran-dplyr

这招很管用。

相关内容