How to install Tidyverse on Ubuntu 16.04 and 17.04

孤街醉人 提交于 2019-11-30 13:12:42

In some cases I find that I need to install the Ubuntu packages. To install the Tidyverse I added

sudo apt-get install r-cran-curl r-cran-openssl r-cran-xml2

After installing these packages, I could install the Tidyverse.

I run into the same problem, using elementary loki, based on ubuntu 16.04. Reading the output, I realized there was a very informative error message, that looked like this

    ------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
 * deb: libssl-dev (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fedora, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

So I followed each prompt, installing the required deb, which came up to

sudo apt-get install libssl-dev libxml2-dev libcurl4-openssl-dev 

and it worked, after I had already tried installing the cran packages listed above, without adding the new repositories.

I believe had a similar problem trying to install the tidyverse package. Being reasonably new to Linux and a complete rookie to R, I followed the Ubuntu installation intructions on the CRAN Project's homepage. When I installed R, I deliberately skipped installation of the r-base-dev package, as it said it was intended for "package maintainers". I didn't really read the latter part or understand the necessity for compiling packages myself.

Anyway, installing r-base-dev package, and allowed me to install the Tidyverse package without problems. The complete steps to get it to work should be something like below. In terminal do the following steps (Step 1-3 may or may not be necessary, but I've added them just in case):

  1. Add deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu artful/ in your /etc/apt/sources.list file, replacing by the actual URL of your favorite CRAN mirror. See https://cran.r-project.org/mirrors.html for the list of CRAN mirrors.
  2. Add the repository key to your system:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
    

    An alternate method can be used by retrieving the key with

    gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
    

    and then feed it to apt-key with

    gpg -a --export E084DAB9 | sudo apt-key add -
    
  3. To install the complete R system, use

    sudo apt-get update
    sudo apt-get install r-base
    
  4. Then comes the step I missed, that proved crucial to be able to compile the packages within the Tidyverse package, namely installing the r-base-dev package:

    sudo apt-get install r-base-dev
    
  5. Then in RStudio execute the package installation command:

    install.packages(tidyverse)
    

Hopefully this will work for you as well. Read the installation guide on the CRAN Projects homepages for further about the installation procedure.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!