Difference between revisions of "R/C2/Installing-R-and-RStudio-on-Linux/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 19: Line 19:
  
 
|| In this tutorial, we will learn how to:
 
|| In this tutorial, we will learn how to:
* Install''' R '''version''' 3.4.4'''
+
* Install''' R '''version 3.4.4
* Install '''RStudio''' version '''1.1.463''' on '''Linux''' OS
+
* Install '''RStudio''' version 1.1.463 on '''Linux''' OS
 
* Open '''RStudio''' interface
 
* Open '''RStudio''' interface
* Install packages
+
* Install '''packages'''
  
 
|-  
 
|-  
Line 30: Line 30:
  
 
|| To install '''R''' and '''RStudio''', I am using,
 
|| To install '''R''' and '''RStudio''', I am using,
* '''Ubuntu Linux '''OS version '''16.04.'''
+
* '''Ubuntu Linux '''OS version 16.04.
* A working Internet connection.
+
* A working '''Internet''' connection.
  
 
|-  
 
|-  
Line 45: Line 45:
  
 
'''sudo apt-get install r-base'''
 
'''sudo apt-get install r-base'''
|| In the '''Terminal''' prompt''', '''type the following command and press '''Enter'''.  
+
|| In the '''Terminal prompt''', type the following '''command''' and press '''Enter'''.  
 
|-  
 
|-  
 
|| Cursor on the Terminal.
 
|| Cursor on the Terminal.
  
 
Type the password >> Press '''Enter'''.
 
Type the password >> Press '''Enter'''.
|| The machine will ask for the system password.
+
|| The machine will ask for the '''system password'''.
  
Type the password and press '''Enter'''.
+
Type the '''password''' and press '''Enter'''.
 
|-  
 
|-  
 
|| Highlight the running commands in the '''Terminal'''  
 
|| Highlight the running commands in the '''Terminal'''  
Line 59: Line 59:
 
|| The installation for '''R''' begins.
 
|| The installation for '''R''' begins.
  
Press '''Y''' to continue the installation process whenever prompted.
+
Press '''Y''' and press '''Enter''' to continue the installation process whenever prompted.
 
|-  
 
|-  
 
|| Cursor on the '''Terminal'''.
 
|| Cursor on the '''Terminal'''.
Line 65: Line 65:
 
|-  
 
|-  
 
|| Highlight processing triggers statements in the '''Terminal'''  
 
|| Highlight processing triggers statements in the '''Terminal'''  
|| '''R''' is now''' '''installed on our machine.  
+
|| '''R''' is now installed on our machine.  
 
|-  
 
|-  
 
|| Cursor on the '''Terminal'''.
 
|| Cursor on the '''Terminal'''.
Line 90: Line 90:
 
|-  
 
|-  
 
|| Highlight > on the '''Terminal'''  
 
|| Highlight > on the '''Terminal'''  
|| Here, we can run the commands using the command-line interface.  
+
|| Here, we can run the '''commands''' by using the '''command-line''' interface.  
  
 
Let us perform some mathematical operations using '''R'''.  
 
Let us perform some mathematical operations using '''R'''.  
Line 97: Line 97:
  
 
'''exp(1)'''
 
'''exp(1)'''
|| We will compute the value of mathematical constant '''e. '''Remember,''' e '''is the base of the natural logarithm.  
+
|| 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'''.  
 
In the '''Terminal''', type '''exp''' followed by 1 in parentheses and press '''Enter'''.  
Line 114: Line 116:
  
 
'''q()'''
 
'''q()'''
|| In the '''Terminal''', type q followed by parentheses and press '''Enter'''.  
+
|| In the '''Terminal''', type '''q''' followed by parentheses and press '''Enter'''.  
 
|-  
 
|-  
 
|| Highlight '''Save workspace image?''' In the '''Terminal'''
 
|| Highlight '''Save workspace image?''' In the '''Terminal'''
|| It asks whether you want to save the workspace image.  
+
|| It asks whether you want to save the '''workspace image'''.  
  
 
As we have nothing to save, type '''n '''and press '''Enter'''.
 
As we have nothing to save, type '''n '''and press '''Enter'''.
Line 129: Line 131:
 
|-  
 
|-  
 
|| Cursor on the terminal.
 
|| Cursor on the terminal.
|| Now, we will install '''RStudio '''version''' 1.1.463'''.  
+
|| Now, we will install '''RStudio '''version 1.1.463.  
  
For this, we need to download the corresponding '''d e b''' file using the '''wget''' command.
+
For this, we need to download the corresponding '''d e b''' file using the '''w get command. '''
 
|-  
 
|-  
 
|| [Terminal]  
 
|| [Terminal]  
  
 
'''sudo apt-get install -y g++ wget'''
 
'''sudo apt-get install -y g++ wget'''
|| Let us install the '''wget''' utility first.  
+
|| Let us install the '''w get''' utility first.  
  
In the '''Terminal''', type the following command and press '''Enter'''.  
+
In the '''Terminal''', type the following '''command''' and press '''Enter'''.  
  
We will wait until the installation of '''wget''' is complete.  
+
We will wait until the installation of '''w get''' is complete.  
 
|-  
 
|-  
 
|| Highlight '''Setting up wget''' in the '''Terminal'''
 
|| Highlight '''Setting up wget''' in the '''Terminal'''
|| '''wget''' is now installed on the machine.
+
|| '''w get''' is now installed on the machine.
 
|-  
 
|-  
 
|| Cursor in the '''Terminal'''
 
|| Cursor in the '''Terminal'''
Line 151: Line 153:
  
 
'''cd '''
 
'''cd '''
|| We will change the working directory to '''home'''.  
+
|| We will change the '''working directory''' to '''Home'''.  
  
 
In the '''Terminal''' window, type '''cd''' and press '''Enter'''.  
 
In the '''Terminal''' window, type '''cd''' and press '''Enter'''.  
  
Let us download the '''d e b''' file for '''RStudio version 1.1.463'''.  
+
Let us download the '''d e b''' file for '''RStudio''' version 1.1.463.  
 
|-  
 
|-  
 
|| [Terminal]
 
|| [Terminal]
  
 
'''wget http://download1.rstudio.org/rstudio-1.1.463-amd64.deb'''
 
'''wget http://download1.rstudio.org/rstudio-1.1.463-amd64.deb'''
|| In the '''Terminal''', type the following command and press '''Enter'''.  
+
|| In the '''Terminal''', type the following '''command''' and press '''Enter'''.  
  
 
We will wait until the '''d e b''' file has been downloaded.  
 
We will wait until the '''d e b''' file has been downloaded.  
 
|-  
 
|-  
|| Highlight '''rstudio-1.1.463-amd64.deb''' '''saved''' in the '''Terminal'''  
+
|| Highlight '''rstudio-1.1.463-amd64.deb''' saved in the '''Terminal'''  
|| The '''deb''' file has been downloaded.  
+
|| The '''d e b''' file has been downloaded.  
 
|-  
 
|-  
 
|| [Terminal]
 
|| [Terminal]
Line 180: Line 182:
  
 
'''sudo apt-get install -y gdebi-core'''
 
'''sudo apt-get install -y gdebi-core'''
|| In the '''Terminal''', type the following command and press '''Enter'''.  
+
|| In the '''Terminal''', type the following '''command''' and press '''Enter'''.  
  
 
We will wait until the installation of '''g d e b i''' is complete.  
 
We will wait until the installation of '''g d e b i''' is complete.  
 
|-  
 
|-  
 
|| Highlight '''Setting up gdebi-core''' in the '''Terminal'''  
 
|| Highlight '''Setting up gdebi-core''' in the '''Terminal'''  
|| '''gdebi''' has been installed.  
+
|| '''g d e b i''' has been installed.  
  
 
|-  
 
|-  
Line 196: Line 198:
  
 
'''sudo gdebi rstudio-1.1.463-amd64.deb'''
 
'''sudo gdebi rstudio-1.1.463-amd64.deb'''
|| Now, we will install the '''deb''' file for '''RStudio''' using '''g d e b i''' utility.  
+
|| 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'''.  
+
In the '''Terminal''', type the following '''command''' and press '''Enter'''.  
 
|-  
 
|-  
 
|| Highlight''' Do you want to install the software package? [y/N]''' in the '''Terminal'''
 
|| Highlight''' Do you want to install the software package? [y/N]''' in the '''Terminal'''
Line 227: Line 229:
 
|-  
 
|-  
 
|| Highlight the greater than symbol in the '''Console''' window  
 
|| Highlight the greater than symbol in the '''Console''' window  
|| Now, we will run a plot command.  
+
|| Now, we will run a '''plot command'''.  
 
|-  
 
|-  
 
|| [RStudio]
 
|| [RStudio]
  
 
'''plot(1:5)'''
 
'''plot(1:5)'''
|| In the '''Console''' window, type '''plot''' now in parentheses 1:5 and press '''Enter'''.  
+
|| In the '''Console''' window, type '''plot'''.
 +
 
 +
Now in parentheses 1:5 and press '''Enter'''.  
 
|-  
 
|-  
 
|| Highlight the plot in the '''Plots''' window  
 
|| Highlight the plot in the '''Plots''' window  
Line 241: Line 245:
 
|-  
 
|-  
 
||  
 
||  
|| Now, we will install a few packages which will be required later in this series.  
+
|| Now, we will install a few '''packages''' which will be required later in this series.  
 
|-  
 
|-  
 
|| Show slide
 
|| Show slide
Line 247: Line 251:
 
Installing Packages  
 
Installing Packages  
 
|| We will install  
 
|| We will install  
* '''plyr'''
+
* '''p l y r'''
 
* '''MASS'''
 
* '''MASS'''
 
* '''ggplot2''' and  
 
* '''ggplot2''' and  
* '''dplyr'''  
+
* '''d p l y r'''  
  
 
|-  
 
|-  
Line 261: Line 265:
  
 
'''install.packages("plyr")'''
 
'''install.packages("plyr")'''
|| In the Console window, type the following command and press '''Enter'''.
+
|| In the '''Console''' window, type the following '''command''' and press '''Enter'''.
  
 
We will wait until the installation is complete.  
 
We will wait until the installation is complete.  
 
|-  
 
|-  
 
|| Highlight '''DONE (plyr)''' in '''RStudio'''
 
|| Highlight '''DONE (plyr)''' in '''RStudio'''
|| '''plyr''' package is now installed.  
+
|| '''plyr package''' is now installed.  
 
|-  
 
|-  
 
|| Cursor in the '''Console''' window of '''RStudio'''
 
|| Cursor in the '''Console''' window of '''RStudio'''
Line 281: Line 285:
  
 
'''install.packages("MASS")'''
 
'''install.packages("MASS")'''
|| Now, we will install another package named as '''MASS'''.  
+
|| Now, we will install another '''package''' named as '''MASS'''.  
  
Type the following command and press '''Enter'''.
+
Type the following '''command''' and press '''Enter'''.
  
 
We will wait until the installation is complete.  
 
We will wait until the installation is complete.  
 
|-  
 
|-  
 
|| Highlight '''DONE (MASS) '''in '''RStudio'''
 
|| Highlight '''DONE (MASS) '''in '''RStudio'''
|| '''MASS''' package is now installed.  
+
|| '''MASS package''' is now installed.  
 
|-  
 
|-  
 
|| Cursor in the '''Console''' window of '''RStudio'''
 
|| Cursor in the '''Console''' window of '''RStudio'''
Line 303: Line 307:
  
 
'''install.packages("ggplot2")'''
 
'''install.packages("ggplot2")'''
|| Now, we will install '''ggplot2 '''Package.
+
|| Now, we will install '''ggplot2 package'''.
  
In the '''Console''' window, type the following command and press '''Enter'''.
+
In the '''Console''' window, type the following '''command''' and press '''Enter'''.
  
 
We will wait until the installation is complete.  
 
We will wait until the installation is complete.  
  
Depending upon your speed of the Internet, it may take 4 to 5 minutes.  
+
Depending upon your speed of the '''Internet''', it may take 4 to 5 minutes.  
 
|-  
 
|-  
 
|| Highlight '''DONE (ggplot2)''' in '''RStudio'''
 
|| Highlight '''DONE (ggplot2)''' in '''RStudio'''
|| '''ggplot2''' package is now installed.  
+
|| '''ggplot2 package''' is now installed.  
  
 
|-  
 
|-  
Line 328: Line 332:
  
 
'''install.packages("dplyr")'''
 
'''install.packages("dplyr")'''
|| Now, we will install '''dplyr '''package.
+
|| Now, we will install '''dplyr package'''.
  
In the '''Console''' window, type the following command and press '''Enter'''.
+
In the '''Console''' window, type the following '''command''' and press '''Enter'''.
  
 
We will wait until the installation is complete.  
 
We will wait until the installation is complete.  
  
Depending upon the speed of the Internet, it may take 4 to 5 minutes.  
+
Depending upon the speed of the '''Internet''', it may take 4 to 5 minutes.  
 
|-  
 
|-  
 
|| Highlight '''DONE (dplyr)''' in '''RStudio'''
 
|| Highlight '''DONE (dplyr)''' in '''RStudio'''
|| '''dplyr''' package is now installed.  
+
|| '''dplyr package''' is now installed.  
 
|-  
 
|-  
 
||  
 
||  
Line 346: Line 350:
 
Summary
 
Summary
 
|| In this tutorial, we have learnt how to,
 
|| In this tutorial, we have learnt how to,
* Install''' R '''version''' 3.4.4'''
+
* Install''' R '''version 3.4.4  
* Install '''RStudio''' version '''1.1.463''' on '''Linux''' OS
+
* Install '''RStudio''' version 1.1.463 on '''Linux''' OS
 
* Open '''RStudio''' interface
 
* Open '''RStudio''' interface
* Install packages
+
* Install '''packages'''
  
 
|-  
 
|-  

Revision as of 18:25, 3 October 2019

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

Press y to continue.

The installation for R begins.

Press 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.

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

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 window, 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