Monday, September 21, 2020

how to install R in ubuntu ?

R is an open-source programming language and free environment that specialises in statistical computing and graphical representation. It is mainly used by statisticians and data miners for developing statistical software and performing data analysis

add to /etc/apt/sources.list

deb https://cloud.r-project.org/bin/linux/ubuntu trusty/


Installation

To obtain the latest R 4.0 packages, add an entry like


deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/

or


deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/

or


deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/




To obtain the latest R 3.6 packages, use:


deb https://cloud.r-project.org/bin/linux/ubuntu eoan-cran35/

or


deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/

or


deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/

or


deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/

To obtain the latest R 3.4 packages, use:


deb https://cloud.r-project.org/bin/linux/ubuntu xenial/

or


deb https://cloud.r-project.org/bin/linux/ubuntu trusty/



sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/'

sudo apt-get update

sudo apt-get install r-base

sudo apt-get install r-base-dev xml2 libxml2-dev libssl-dev libcurl4-openssl-dev unixodbc-dev


If we want to upgrade to the latest version 

sudo apt-get install r-base-dev --reinstall

To install any package under R Example Below 

sudo R

install.packages("tidyverse")


after installation


R


library(tidyverse)

── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──

✔ ggplot2 3.2.1     ✔ purrr   0.3.3

✔ tibble  2.1.3     ✔ dplyr   0.8.3

✔ tidyr   1.0.0     ✔ stringr 1.4.0

✔ readr   1.3.1     ✔ forcats 0.4.0

── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──

✖ dplyr::filter() masks stats::filter()

✖ dplyr::lag()    masks stats::lag()


Reference :

 https://cran.r-project.org/bin/linux/ubuntu/README.html