How to Install R on Linux Ubuntu 16.04 Xenial Xerus

The long-awaited new Ubuntu LTS Xenial Xerus was released last week. I wrote a tutorial on installing R and R-Studio on the old 14.04 LTS, so I figured I’d update that document. Not much has changed for the new 16.04 version but there are new repositories.

Install R-Base

You can find R-Base in the Software Center; this would be the easy way to do it. However, the Software Center versions are often out of date, which can be a pain moving foward when your packages are based on the most current version of R Base. The easy fix is to download and install R Base directly from the Cran servers.

1. Add R repository

First, we’ve got to add a line to our /etc/apt/sources.list file. This can be accomplished with the following. Note the “xenial” in the line, indicating Ubuntu 16.04. If you have a different version, just change that.

sudo echo "deb xenial/" | sudo tee -a /etc/apt/sources.list

2. Add R to Ubuntu Keyring


 gpg --keyserver --recv-key E084DAB9


 gpg -a --export E084DAB9 | sudo apt-key add -

3. Install R-Base

Most Linux users should be familiar with the old…

sudo apt-get update
sudo apt-get install r-base r-base-dev

Installing R-Studio

RStudio is not currently in the Software Center, but it can easily be installed manually:

sudo apt-get install gdebi-core
sudo gdebi -n rstudio-1.0.44-amd64.deb
rm rstudio-1.0.44-amd64.deb


37 thoughts on “How to Install R on Linux Ubuntu 16.04 Xenial Xerus

  1. Thank you for your so up-to-date and detailed information!

    Just to help if anyone have the same problem, I got an error of ‘keyserver unreachable’ from, which I had solved by specifying the protocol and port number as follows:
    gpg –keyserver hkp:// –recv-key E084DAB9

    1. Still having problem..It shows
      “gpg: fatal: can’t create directory `/HOME/akshay/jdk1.8.0_101/bin//.gnupg’: No such file or directory
      secmem usage: 0/0 bytes in 0/0 blocks of pool 0/65536”

  2. Thanx for the article.

    Cant get RStudio started though 🙁

    I am getting “load glyph failed”, any ideas? I cant find anything useful on the web. Tried latest version of Rstudio as well and the same issue.


    1. I tried to replicate the problem with a fresh install of 16.04 but can’t. You’re not running VNC by chance are you? I’ve seen this same issue with machines running VNC servers. The (for now) fix seems to be to uninstall the current version of RStudio and then grab the older one.

      `sudo gdebi -n rstudio-0.98.1103-amd64.deb`

  3. Thank you very much for the article.
    I am pretty new In Linux and I don’t know if it works for all flavors of Ubuntu, for example, Ubuntu Mate.

    1. Glad to help. Yes, it should work on MATE. I tested this on Ubuntu Server, which is the most stripped down version out there. Most of the “flavors” are just different desktop environments.

  4. Thanks for post.
    I can load rstudio, but in the terminal I get this error message:
    load glyph failed err=6 face=0x207d280, glyph=2797
    load glyph failed err=6 face=0x207d280, glyph=2797

    When I close rstudio I get this one:
    QApplication::qAppName: Please instantiate the QApplication object first

    Do you know what could it be?
    Thanks for the help.
    Best Regards,

    1. Try re-installing gdebi. If you’re using command line it’s sudo apt-get install gdebi-core or if you prefer a GUI you can just sudo apt-get install gdebi

  5. Please I am struggling trying to install Rstudio. I have follow the instruction but after typing:
    sudo gdebi -n rstudio-0.99.903-amd64.deb I got the error:
    This package can not be installed
    Wrong architecture ‘amd64’

    does anyone know how to solve this?

    1. The `wget` command is just downloading the rstudio.deb file. Usually a “segmentation fault” error would occur during installation–probably at the `sudo gdebi` line below. Either way, I assume your using Ubuntu desktop, you could always try installing Rstudio via the Software Centre.

      1. Thank you for your answer. Usually it’s easier for me to use the terminal, but I’ve installed it from the Software Centre as you advised. I get this message when I try to open it:
        The R session failed to start.

        /usr/lib/rstudio/bin/rsession: symbol lookup error: /usr/lib/rstudio/bin/rsession: undefined symbol: Rf_PrintWarnings

        Any idea? As you can imagine, I’m not an expert in Linux, nor in R, sorry if it’s something obvious.

        1. Nevermind, I removed both R and R Studio and reinstalled them and now it looks like it’s finally working 🙂

  6. Trying to install on 16.10 doing s/xenial/yakkety/g where needed, and there’s an issue with installing R Studio. I get

    This package is uninstallable
    Dependency is not satisfiable: libgstreamer0.10-0

    from the gdebi command to install it. Looking around shows a libgstreamer1.0-0 in the yakkety repository, but no libgstreamer0.10-0.

Leave a Reply