How to install R on Ubuntu 20.04

This article was first published in: https://www.itcoder.tech/posts/how-to-install-r-on-ubuntu-20-04/

R is an open source programming language and free environment, mainly used for statistical analysis and drawing. It is supported by the R Foundation and is mainly used for statistical analysis. It is mainly used by data statistics and analysts to develop statistical software and for data analysis.

This article mainly describes how to install R on Ubuntu 20.04.

1. Prerequisites##

Before proceeding with this guide, please make sure you meet the following prerequisites:

2. Install R on Ubuntu

The R packages included in the default Ubuntu software sources are often out of date. We will install R from the CRAN software source.

To install R on Ubuntu 20.04, follow the steps below:

  1. Install the necessary software packages and add a new software source:
sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common
  1. Add the CRAN software source to your system source list:
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/'
  1. Enter the following command to install R:
sudo apt install r-base
  1. The installation process will take a few minutes to complete. Once completed, print the version of R to verify that it was installed successfully:
R --version

Output:

R version 4.0.1(2020-06-06)--"See Things Now"Copyright(C)2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu(64-bit)...

that's it. R has been installed on your Ubuntu machine, and you can start using it.

Three, compile R software package##

One of the main reasons for R's popularity is that many software packages are provided through the Comprehensive R Archive Network (CRAN).

To compile the R package, you need to install the build-essential package:

sudo apt install build-essential

To demonstrate, we will install a package called stringr, which provides a quick implementation of common string operations.

When you run as root, the package will be installed globally and available to all system users. If you start R without using sudo, this will only work for the current user.

Open the R terminal:

R

Output:

>

To install the stringr package, enter:

install.packages("stringr")

The installation will take some time. Once completed, enter the following command to load the library:

library(stringr)

Next, create a simple string with the command'tutorial':

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

Running the following function will print out the length of each string:

str_length(tutorial)
[1]3271265

You can find more R packages in CRAN Package Page, and install them via install.packages().

Four, summary##

We have shown you how to install R on Ubuntu 20.04 and how to compile and install R packages.

If you have any questions, please contact us in the following ways:

WeChat:

WeChat group: add the above WeChat, remark the WeChat group

QQ: 3217680847

QQ Group: 82695646

Recommended Posts

How to install R on Ubuntu 20.04
How to install R on Ubuntu 18.04 [Quick Start]
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ubuntu 19.10 on Raspberry Pi 4
How to set up R on Ubuntu 14.04
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04