R/C2/Installing-R-and-RStudio-on-Linux/English

From Script | Spoken-Tutorial
Revision as of 13:04, 4 October 2019 by Madhurig (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of the script: Installing R and RStudio on Linux

Author: Sudhakar Kumar (IIT Bombay)

Keywords: R, RStudio, Linux, Ubuntu 16.04, Packages, ggplot2, dplyr, video tutorial

Visual Cue Narration
Show slide

Opening Slide

Welcome to this tutorial on Installing R and RStudio on Linux.
Show slide

Learning Objective

In this tutorial, we will learn how to:
  • Install R version 3.4.4
  • Install RStudio version 1.1.463 on Linux OS
  • Open RStudio interface
  • Install packages
Show slide

System Specifications

To install R and RStudio, I am using,
  • Ubuntu Linux OS version 16.04.
  • A working Internet connection.
We will install R using the Terminal.
Highlight Terminal on the machine Press Ctrl + Alt + T keys together to open the Terminal on your computer.

Make sure that you are connected to the Internet.

[Terminal]

sudo apt-get install r-base

In the Terminal prompt, type the following command and press Enter.
Cursor on the Terminal.

Type the password >> Press Enter.

The machine will ask for the system password.

Type the password and press Enter.

Highlight the running commands in the Terminal

Type y to continue.

The installation for R begins.

Type Y and press Enter to continue the installation process whenever prompted.

Cursor on the Terminal. We will wait until the installation is complete.
Highlight processing triggers statements in the Terminal R is now installed on our machine.
Cursor on the Terminal. I will clear the Terminal before moving further.

In the Terminal, type clear and press Enter.

Cursor on the Terminal. Let us check if the installation of R is successful.
[Terminal]

R

In the Terminal, type capital R and press Enter.
Highlight R version on the Terminal R is launched.

In the Terminal, scroll up to know the version of R.

We can see that R version 3.4.4 has been installed.

Let us scroll down.

Highlight > on the Terminal Here, we can run the commands by using the command-line interface.

Let us perform some mathematical operations using R.

[R Terminal]

exp(1)

We will compute the value of mathematical constant e.

Remember, e is the base of the natural logarithm.

In the Terminal, type exp followed by 1 in parentheses and press Enter.

Highlight 2.718 in the Terminal The required value is displayed.

It means that R has been installed successfully.

Now, we will proceed to install RStudio.

Highlight R version in the Terminal For this, we need to quit the current session of R.
[R Terminal]

q()

In the Terminal, type q followed by parentheses and press Enter.
Highlight Save workspace image? In the Terminal It asks whether you want to save the workspace image.

As we have nothing to save, type n and press Enter.

[Terminal]

clear, Press Enter.

I will clear the Terminal before moving further.

In the Terminal, type clear and press Enter.

Cursor on the terminal. Now, we will install RStudio version 1.1.463.

For this, we need to download the corresponding d e b file using the w get command.

[Terminal]

sudo apt-get install -y g++ wget

Let us install the w get utility first.

In the Terminal, type the following command and press Enter.

We will wait until the installation of w get is complete.

Highlight Setting up wget in the Terminal w get is now installed on the machine.
Cursor in the Terminal I will clear the Terminal before moving further.
[Terminal]

cd

We will change the working directory to Home.

In the Terminal, type cd and press Enter.

Let us download the d e b file for RStudio version 1.1.463.

[Terminal]

wget http://download1.rstudio.org/rstudio-1.1.463-amd64.deb

In the Terminal, type the following command and press Enter.

We will wait until the d e b file has been downloaded.

Highlight rstudio-1.1.463-amd64.deb saved in the Terminal The d e b file has been downloaded.
[Terminal]

clear

I will clear the Terminal again.
Cursor on the terminal. Now, we need to install g d e b i utility.

This will allow us to install d e b files on our machine.

[Terminal]

sudo apt-get install -y gdebi-core

In the Terminal, type the following command and press Enter.

We will wait until the installation of g d e b i is complete.

Highlight Setting up gdebi-core in the Terminal g d e b i has been installed.
[Terminal]

clear

I will clear the Terminal.
[Terminal]

sudo gdebi rstudio-1.1.463-amd64.deb

Now, we will install the d e b file for RStudio using g d e b i utility.

In the Terminal, type the following command and press Enter.

Highlight Do you want to install the software package? [y/N] in the Terminal It will ask Do you want to install the software package?

Press y to continue.

We will wait until the installation of RStudio is complete.

Highlight Processing triggers in the Terminal RStudio has been installed.
[Terminal]

clear

I will clear the Terminal again.
[Terminal]

rstudio

Now we will verify whether RStudio has been installed successfully.

In the Terminal, type rstudio and press Enter.

Highlight RStudio window RStudio is launched.
Highlight the greater than symbol in the Console window Now, we will run a plot command.
[RStudio]

plot(1:5)

In the Console window, type plot.

Now in parentheses 1:5 and press Enter.

Highlight the plot in the Plots window The required plot is generated.
Highlight Packages in the interface of RStudio In the right lower side of RStudio, click on Packages.
Now, we will install a few packages which will be required later in this series.
Show slide

Installing Packages

We will install
  • p l y r
  • MASS
  • ggplot2 and
  • d p l y r
Let us switch to RStudio.

Make sure that you are connected to the Internet.

[RStudio]

install.packages("plyr")

In the Console window, type the following command and press Enter.

We will wait until the installation is complete.

Highlight DONE (plyr) in RStudio plyr package is now installed.
Cursor in the Console window of RStudio I will clear the Console before moving further.
[RStudio]

Ctrl + L

Click in the Console window.

Now, press Ctrl + L keys together.

[RStudio]

install.packages("MASS")

Now, we will install another package named as MASS.

Type the following command and press Enter.

We will wait until the installation is complete.

Highlight DONE (MASS) in RStudio MASS package is now installed.
Cursor in the Console window of RStudio I will clear the Console window again.
[RStudio]

Ctrl + L

Click in the Console window.

Press Ctrl + L keys together.

[RStudio]

install.packages("ggplot2")

Now, we will install ggplot2 package.

In the Console window, type the following command and press Enter.

We will wait until the installation is complete.

Depending upon your speed of the Internet, it may take 4 to 5 minutes.

Highlight DONE (ggplot2) in RStudio ggplot2 package is now installed.
Cursor in the Console window of RStudio I will clear the Console window again.
[RStudio]

Ctrl + L

Click in the Console window.

Press Ctrl + L keys together.

[RStudio]

install.packages("dplyr")

Now, we will install dplyr package.

In the Console window, type the following command and press Enter.

We will wait until the installation is complete.

Depending upon the speed of the Internet, it may take 4 to 5 minutes.

Highlight DONE (dplyr) in RStudio dplyr package is now installed.
Let us summarize what we have learnt.
Show slide

Summary

In this tutorial, we have learnt how to,
  • Install R version 3.4.4
  • Install RStudio version 1.1.463 on Linux OS
  • Open RStudio interface
  • Install packages
Show slide

About the Spoken Tutorial Project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Show slide

Spoken Tutorial Workshops

We conduct workshops using Spoken Tutorials and give certificates.

Please contact us.

Show Slide

Forum to answer questions

Do you have questions in THIS Spoken Tutorial?

Choose the minute and second where you have the question.

Explain your question briefly.

Someone from the FOSSEE team will answer them.

Please visit this site.

Show Slide

Forum to answer questions

Do you have any general/technical questions?

Please visit the forum given in the link.

Show Slide

Textbook Companion

The FOSSEE team coordinates coding of solved examples of popular books.

We give honorarium and certificates to those who do this.

For more details, please visit these sites.

Show Slide

Acknowledgment

The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India
Show Slide

Thank You

This is Sudhakar Kumar from IIT Bombay signing off. Thanks for watching.

Contributors and Content Editors

Madhurig, Nancyvarkey, Sudhakarst