Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install R on Ubuntu 20.04 - DesignLinux

May 30 2020
designlinux 0 Comments
How to Install R on Ubuntu 20.04

R is an open-source, widely used for developing statistical software and performing data analysis. It is supported by the R Foundation for Statistical Computing. This tutorial explains how to install R on Ubuntu 20.04.

Prerequisites#

  • You should logged in as root or user account with sudo privileges.
  • Ubuntu 20.04 system should have at least 1 GB of RAM.

Installing R on Ubuntu#

R is a fast-moving project, the latest stable version isn’t always available from Ubuntu repositories, so we’ll need to add the external repository maintained by CRAN.

Follow the below steps to install latest stable version of R on Ubuntu:

First, you should install required packages to add new repository. Run following command to install dependencies:

sudo apt install apt-transport-https software-properties-common

Enable CRAN repository and add the CRAN GPG key to your system by issuing below command:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'

Once the repository added you should update package list by typing:

sudo apt update

Next issue below command to install R on Debian:

sudo apt install r-base

Verify the installation by running the following command which will print the R version:

R --version
R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
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 Packages from CRAN#

R has wide range of add-on packages through the Comprehensive R Archive Network (CRAN). You should install build-essential package which contains the tools required for compiling R Packages.

sudo apt install build-essential

For demonstration purposes, we will install stringr package which provides fast, correct implementations of common string manipulations.

Start by opening the R console as root:

sudo -i R

It will show as below:

R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
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.

> 

To install stringr package, type:

install.packages("stringr")

Installation will take some time and after completion load library using:

library(stringr)

Let’s create a simple vector named demo:

demo <- c("How", "to", "Install", "R", "on", "Ubuntu", "20.04")

Now run the below command to print the length of a string:

str_length(demo)
[1] 3 2 7 1 2 6 5

If you want to install more packages you can find it at CRAN Packages.

Conclusion#

You have successfully learned how to install R on Ubuntu 20.04 Focal Fossa.

If you have any problem or suggestion please leave a comment below.

Related

Tags: ubuntu

How to Enable WordPress Debugging Mode to Fix Errors

Prev Post

Lsmod Command in Linux (List Kernel Modules)

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 619
  • 1,055,391

DesignLinux.com © All rights reserved

Go to mobile version