Objective

The objective is to install R, the statistical computation and graphics system on Ubuntu 18.04 Bionic Beaver Linux.

Operating System and Software Versions

  • Operating System: - Ubuntu 18.04 Bionic Beaver
  • Software: - R version 3.4.3 or higher

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Difficulty

EASY

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user

Instructions

Install R on Ubuntu

To install R on your Ubuntu 18.04 system open up the terminal and enter:
$ sudo apt update
$ sudo apt -y install r-base
Once the installation is complete confirm the R installation by checking its version:
$ R --version
R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
To start R simply execute the R command:
$ R

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Install R packages

Many of the packages for R are already pre-compiled and are part of the Ubuntu repository.

In case you need to install a new R package a.k.a library first search Ubuntu's repository before resorting to package installation from source. The following linux command will list all R packages available from Ubuntu repository:
$ apt search r-cran
To narrow down the search to a specific package eg. gplots execute the below command and take a note of the package name:
$ apt search r-cran gplots
Sorting... Done
Full Text Search... Done
r-cran-gplots/bionic,bionic 3.0.1-2.1 all
  GNU R package with tools for plotting data by Greg Warnes et al

r-cran-gregmisc/bionic,bionic 2.1.5-2 all
  GNU R package with miscellaneous functions by Greg Warnes et al
At this stage there is no gplots library available yet:
$ R
> library(gplots)
Error in library(gplots) : there is no package called ‘gplots’
To install gplots simply use the apt command and the package name retrieved earlier:
$ sudo apt install r-cran-gplots
The package is now installed:
$ R
> library(gplots)
Attaching package: ‘gplots’

Install R packages from source

Follow our guide on how to install and use packages in GNU R in case you need a package which is not currently available for installation from the standard Ubuntu repository or you require a higher package version number.
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.