Installing R Stats on Linux

Lee Hawthorn June 01, 2019 #R

Running R on Linux is better in some cases as you have a full build environment for packages. These are compiled from C/Fortran. If you have software engineers in house this allows any mods to be made to source code if you need it.

I use Linux Mint 19.1 which is based on Ubuntu 18.04.

To install the latest version of R at the time of writing 3.6.0 I used the following steps:

  1. Add a repo to my /etc/apt/sources.list file

    deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/

    Note this is specific to the Ubuntu base packages I have. If on a different version of Ubuntu you can check the correct repo here

  2. From a terminal run

    sudo apt-get update
    sudo apt-get install r-base r-base-dev
    
  3. There are some extra libraries to install for common packages hence run these commands:

    sudo apt-get install libssl-dev libxml2-dev libcurl4-openssl-dev unixodbc unixodbc-dev libiodbc2-dev libmyodbc odbc-postgresql
    
  4. Install R Studio - I downloaded this one for Ubuntu 18.04

    Once downloaded install the package with your package manager.

  5. To get started with R I recommend installing tidyverse. This is a collection of packages to make data science easier.

    Open up R Studio and run install.packages("tidyverse")

    This will take a while as a number of packages have to be downloaded and built.

  6. If you need to talk to databases over ODBC install RODBC with install.packages("RODBC")

  7. Another package I recommend is Shiny. This app lets you write web apps for your R code to be used by non-techies. Run install.packages("shiny")

This should get you a good clean install with a base set of packages.

rstudio