ObjectiveThe 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
RequirementsPrivileged access to your Ubuntu System as root or via
sudocommand is required.
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
- $ - requires given linux commands to be executed as a regular non-privileged user
Other Versions of this TutorialUbuntu 20.04 (Focal Fossa)
Install R on UbuntuTo install R on your Ubuntu 18.04 system open up the terminal and enter:
$ sudo apt update $ sudo apt -y install r-baseOnce 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 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. >
Install R packagesMany 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-cranTo narrow down the search to a specific package eg.
gplotsexecute 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 alAt this stage there is no
gplotslibrary available yet:
$ R > library(gplots) Error in library(gplots) : there is no package called ‘gplots’To install
gplotssimply use the
aptcommand and the package name retrieved earlier:
$ sudo apt install r-cran-gplotsThe package is now installed:
$ R > library(gplots) Attaching package: ‘gplots’