Install R in Ubuntu 16.04

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5221
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

These instructions will enable you to install R to the newly released Ubuntu 16.04 LTS (Xenial Xerus) and be able to instantly upgrade to the most update packages required by R.

1. Add R Repository to the sources list /etc/apt/sources.list:

Code: Select all

sudo echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list
2. Add R to Ubuntu Keyring (See alternatives at https://cran.r-project.org/bin/linux/ubuntu/README)

Code: Select all

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E084DAB9
and then feed it to apt-key with

Code: Select all

gpg -a --export E084DAB9 | sudo apt-key add -
3. Install R-Base

Code: Select all

sudo apt-get update
sudo apt-get install r-base r-base-dev
4. Finally, install RStudio (This is for 64-bit machine, change parameters to suit 32-bit)

Code: Select all

sudo apt-get install gdebi-core
wget https://download1.rstudio.org/rstudio-0.99.896-amd64.deb
sudo gdebi -n rstudio-0.99.896-amd64.deb
rm rstudio-0.99.896-amd64.deb
To install R packages, you can use Terminal, Synaptic Package Manager or Ubuntu Software Center.

To install R packages through Terminal, code

Code: Select all

install.packages("package_name")
For example, to install R packages swirl and deSolve, go to Terminal and type

Code: Select all

R
install.packages("swirl")
install.packages("deSolve")
Load the package by making its contents available to use in your current R session by running

Code: Select all

library("package_name")
See a list of popular R packages at https://support.rstudio.com/hc/en-us/ar ... R-packages

Note:

If you need to install swirl package in Linux, first, install libcurl by running

Code: Select all

$ sudo apt-get install libcurl4-openssl-dev
libcurl is required for the RCurl package, which swirl uses to download courses from the internet.

You may get an error during swirl installation, the common one is

Code: Select all

installation of package ‘openssl’ had non-zero exit status

To solve the problem, install "libssl-dev" package through Synaptic Package Manager or run in the command line

Code: Select all

sudo apt-get install libssl-dev/unstable
and then install swirl package.

To install courses in swirl, enter the following from the R console, substituting the name of the course by the actual course name that you wish to install:

Code: Select all

library(swirl)
install_from_swirl("Course Name Here")
swirl()
For example, to install R Programming course, enter

Code: Select all

install_from_swirl("R Programming")

Please note that course names are case sensitive!

For more information, including available courses go to https://github.com/swirldev/swirl_courses

Enjoy!
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5221
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#2

To upgrade R, for example on Ubuntu Xenial Xerus, open the Terminal and execute the following lines:

  1. echo "deb https://cloud.r-project.org/bin/linux/ubuntu xenial/" | sudo tee -a /etc/apt/sources.list.d/cran.list
  2. echo "deb https://archive.ubuntu.com/ xenial-backports main restricted universe" | sudo tee -a /etc/apt/sources.list.d/cran.list
  3. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
  4. sudo apt-get update
  5. sudo apt-get install r-base r-base-dev r-recommended

0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux and Unix Based Operating Systems”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest