{"id":4080,"date":"2021-02-05T16:16:33","date_gmt":"2021-02-05T16:16:33","guid":{"rendered":"https:\/\/linuxways.net\/?p=4080"},"modified":"2021-02-05T16:20:18","modified_gmt":"2021-02-05T16:20:18","slug":"how-to-install-r-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-r-on-ubuntu-20-04\/","title":{"rendered":"How to Install R on Ubuntu 20.04"},"content":{"rendered":"<p>R Programming language is an open-source and free software environment that is specifically used for statistical computing and graphical data representation. R software is specially designed for data miners for developing statistical applications, and statisticians for performing data analysis.<\/p>\n<p>In this article, we will give you a brief demo on how to install the R programming language on Linux Ubuntu distribution. All steps we have executed on Ubuntu 20.04 system in this article. Let\u2019s start the R installation!<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>The following requirements should meet for R installation on Ubuntu 20.04 system:<\/p>\n<ol>\n<li>System RAM should have at least 1 GB.<\/li>\n<li>You should have root or to run sudo command privileges.<\/li>\n<\/ol>\n<h2><strong>Installation of R on Ubuntu 20.04<\/strong><\/h2>\n<p>The R packages, available in the default Ubuntu repository are outdated. Therefore, it is the best alternative to install R from the CRAN repository. So, implement the below-mentioned steps in order to install R on Ubuntu 20.04 system by using the CRAN repository:<\/p>\n<h3><strong>Step 1: Install Required Dependencies<\/strong><\/h3>\n<p>Launch the terminal by pressing \u2018Ctrl + Alt + t\u2019 or open the terminal by clicking on the \u2018Activities\u2019 and type terminal in the search bar as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"954\" height=\"258\" class=\"wp-image-4081\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-48.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-48.png 954w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-48-300x81.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-48-768x208.png 768w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/p>\n<p>First, install the all required packages that are necessary for adding a new CRAN repository. Execute the following command to install all dependencies:<\/p>\n<pre>$ sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common<\/pre>\n<p>The following output shows on the terminal window:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"632\" class=\"wp-image-4082\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-49.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-49.png 992w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-49-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-49-768x489.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<h3><strong>Step 2: Add Cran Repository<\/strong><\/h3>\n<p>Add the Cran repository by running the following commands in the terminal:<\/p>\n<pre>$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"986\" height=\"145\" class=\"wp-image-4083\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-50.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-50.png 986w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-50-300x44.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-50-768x113.png 768w\" sizes=\"auto, (max-width: 986px) 100vw, 986px\" \/><\/p>\n<pre>$ sudo add-apt-repository 'deb <a href=\"https:\/\/cloud.r-project.org\/bin\/linux\/ubuntu%20focal-cran40\/\">https:\/\/cloud.r-project.org\/bin\/linux\/ubuntu focal-cran40\/<\/a>'<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"984\" height=\"580\" class=\"wp-image-4084\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-51.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-51.png 984w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-51-300x177.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-51-768x453.png 768w\" sizes=\"auto, (max-width: 984px) 100vw, 984px\" \/><\/p>\n<h3><strong>Step 3: Install R\u00a0<\/strong><\/h3>\n<p>Execute the below-given command to install R on your Ubuntu 20.04 system:<\/p>\n<pre>$ sudo apt install r-base<\/pre>\n<p>When you will run the above command the following R packages installs on your system:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"976\" height=\"593\" class=\"wp-image-4085\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-52.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-52.png 976w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-52-300x182.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-52-768x467.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/p>\n<h3><strong>Step 4: Check R version<\/strong><\/h3>\n<p>Once the R is installed, type the following command to check the installed version of R programming software:<\/p>\n<pre>$ R --version<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"188\" class=\"wp-image-4086\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-53.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-53.png 796w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-53-300x71.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-53-768x181.png 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/p>\n<p>From the following output, it is verified that R is installed on your system now.<\/p>\n<h3><strong>Step 5: Install essential build packages<\/strong><\/h3>\n<p>R has a variety of packages. Therefore, before starting the compilation process install some essential packages that are required for compiling R programs.<\/p>\n<p>The following command can be used to install the required build packages:<\/p>\n<pre>$ sudo apt install build-essential<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"906\" height=\"230\" class=\"wp-image-4087\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-54.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-54.png 906w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-54-300x76.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-54-768x195.png 768w\" sizes=\"auto, (max-width: 906px) 100vw, 906px\" \/><\/p>\n<h3><strong>Step 6: Access R Console<\/strong><\/h3>\n<p>First, type the following command to access the R shell environment where you can install the required R packages:<\/p>\n<pre>$ sudo -i R<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"881\" height=\"358\" class=\"wp-image-4088\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-55.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-55.png 881w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-55-300x122.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-55-768x312.png 768w\" sizes=\"auto, (max-width: 881px) 100vw, 881px\" \/><\/p>\n<p>Now, you can install all R packages on your system.<\/p>\n<h3><strong>Example:<\/strong><\/h3>\n<p>In this example, install the \u2018txtplot\u2019 package that plots the graph of given values. Install the R package \u2018txtplot\u2019 by typing the following terminal command:<\/p>\n<pre>&gt; install.packages(\u201ctxtplot\u201d)<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1081\" height=\"414\" class=\"wp-image-4089\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-56.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-56.png 1081w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-56-300x115.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-56-1024x392.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-56-768x294.png 768w\" sizes=\"auto, (max-width: 1081px) 100vw, 1081px\" \/><\/p>\n<p>Now, load the \u2018txtplot\u2019 library by running the following command:<\/p>\n<pre>&gt; library(\u201ctxtplot\u201d)<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"832\" height=\"31\" class=\"wp-image-4090\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-57.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-57.png 832w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-57-300x11.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-57-768x29.png 768w\" sizes=\"auto, (max-width: 832px) 100vw, 832px\" \/><\/p>\n<p>In this example, we have explained the basic overview of the graph plot between the car acceleration and speed.<\/p>\n<pre>&gt; txtplot(cars[,1], cars[,2], xlab = \u201cacceleration\u201d, ylab = \u201cspeed\u201d)<\/pre>\n<p>The above command displays the following graph on the terminal:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"314\" class=\"wp-image-4091\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-58.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-58.png 875w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-58-300x108.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-58-768x276.png 768w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/p>\n<p>To exit from the R console, type the following command on the terminal:<\/p>\n<pre>&gt; q()<\/pre>\n<p>The following prompt will appear for saving the above workspace image:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"58\" class=\"wp-image-4092\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-59.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-59.png 946w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-59-300x18.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/02\/word-image-59-768x47.png 768w\" sizes=\"auto, (max-width: 946px) 100vw, 946px\" \/><\/p>\n<p>Press \u2018y\u2019 if you want to save the workspace.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We have covered all details related to R installation on Ubuntu 20.04 system in this article. We have also given you a brief demo on how you can install R packages and utilize them according to your needs. We have installed a graphical plotting package in this article. You can install more R packages by using the install.packages() command. Thanks for reading this useful article.<\/p>","protected":false},"excerpt":{"rendered":"<p>R Programming language is an open-source and free software environment that is specifically used for statistical computing and graphical data representation. R software is specially designed for data&hellip;<\/p>","protected":false},"author":2,"featured_media":4096,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[100],"class_list":["post-4080","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/4080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=4080"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/4080\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/4096"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=4080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=4080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=4080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}