Ubuntu – How to install latest rlang and dplyr

18.04r

I want to execute a script that starts with

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

I started out with regular r-base-core and r-cran-lubridate installed.
I got:

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

(the code itself doesn't use mutate_impl it seems to be this issue https://github.com/r-lib/rlang/issues/674, suggesting an update of dplyr

r version was R version 3.4.4 (2018-03-15) for dplyr I didn't know how to find out.

So I changed the source as described elsewhere:
added deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ to /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.

I ran

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

but nothing changed.
Installing it from within the R shell doesn't work either:

> 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
> 

Best Answer

I also could not install dplyr in Ubuntu 18.04. I had R version 3.6.1, which seemingly caused the problem.

I followed this solution and did the following

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

which did the trick.