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

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of the script''': Installing R and RStudio on Linux '''Author''': Sudhakar Kumar (IIT Bombay) '''Keywords''': R, RStudio, Linux, Ubuntu 16.04, Packages, ggplot2, d...")
 
Line 6: Line 6:
  
 
{| border =1
 
{| border =1
|'''Visual Cue’’’
+
|'''Visual Cue'''
|'''Narration’’’
+
|'''Narration'''
 
|-
 
|-
 
|| Show slide  
 
|| Show slide  
Line 17: Line 17:
  
 
Learning Objective
 
Learning Objective
 
 
  
 
|| In this tutorial, we will learn how to:
 
|| In this tutorial, we will learn how to:
Line 25: Line 23:
 
* Open '''RStudio''' interface
 
* Open '''RStudio''' interface
 
* Install packages
 
* Install packages
 
  
 
|-  
 
|-  
Line 32: Line 29:
 
* '''Ubuntu Linux '''OS version '''16.04.'''
 
* '''Ubuntu Linux '''OS version '''16.04.'''
 
* A working Internet connection.
 
* A working Internet connection.
 
  
 
|-  
 
|-  
Line 40: Line 36:
 
|| Highlight '''Terminal''' on the machine  
 
|| Highlight '''Terminal''' on the machine  
 
|| Press '''Ctrl''' + '''Alt''' + '''T''' keys together to open the '''Terminal''' on your computer.  
 
|| Press '''Ctrl''' + '''Alt''' + '''T''' keys together to open the '''Terminal''' on your computer.  
 
  
 
Make sure that you are connected to the '''Internet'''.  
 
Make sure that you are connected to the '''Internet'''.  
Line 50: Line 45:
 
|-  
 
|-  
 
|| 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'''  
 
  
 
Press y to continue.
 
Press y to continue.
 
|| The installation for '''R''' begins.
 
|| The installation for '''R''' begins.
 
  
 
Press '''Y''' to continue the installation process whenever prompted.
 
Press '''Y''' to continue the installation process whenever prompted.
Line 75: Line 66:
 
|| Cursor on the '''Terminal'''.
 
|| Cursor on the '''Terminal'''.
 
|| I will clear the '''Terminal''' before moving further.  
 
|| I will clear the '''Terminal''' before moving further.  
 
  
 
In the '''Terminal''', type '''clear''' and press '''Enter'''.  
 
In the '''Terminal''', type '''clear''' and press '''Enter'''.  
Line 89: Line 79:
 
|| Highlight '''R version''' on the '''Terminal'''  
 
|| Highlight '''R version''' on the '''Terminal'''  
 
|| '''R''' is launched.  
 
|| '''R''' is launched.  
 
  
 
In the '''Terminal''', scroll up to know the version of '''R'''.  
 
In the '''Terminal''', scroll up to know the version of '''R'''.  
 
  
 
We can see that '''R version 3.4.4''' has been installed.  
 
We can see that '''R version 3.4.4''' has been installed.  
 
  
 
Let us scroll down.  
 
Let us scroll down.  
Line 101: Line 88:
 
|| 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 using the command-line interface.  
 
  
 
Let us perform some mathematical operations using '''R'''.  
 
Let us perform some mathematical operations using '''R'''.  
Line 109: Line 95:
 
'''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 115: Line 100:
 
|| Highlight 2.718 in the '''Terminal'''  
 
|| Highlight 2.718 in the '''Terminal'''  
 
|| The required value is displayed.  
 
|| The required value is displayed.  
 
  
 
It means that '''R''' has been installed successfully.  
 
It means that '''R''' has been installed successfully.  
 
  
 
Now, we will proceed to install '''RStudio'''
 
Now, we will proceed to install '''RStudio'''
Line 132: Line 115:
 
|| 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 140: Line 122:
 
'''clear'''
 
'''clear'''
 
|| I will clear the '''Terminal''' before moving further.  
 
|| I will clear the '''Terminal''' before moving further.  
 
  
 
In the '''Terminal''', type '''clear''' and press '''Enter'''.  
 
In the '''Terminal''', type '''clear''' and press '''Enter'''.  
Line 146: Line 127:
 
|| 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 '''wget''' command.  
Line 154: Line 134:
 
'''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 '''wget''' 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 '''wget''' is complete.  
Line 171: Line 149:
 
'''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'''.  
Line 182: Line 158:
 
'''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.  
Line 196: Line 171:
 
|| Cursor on the terminal.
 
|| Cursor on the terminal.
 
|| Now, we need to install '''g d e b i''' utility.  
 
|| Now, we need to install '''g d e b i''' utility.  
 
  
 
This will allow us to install '''d e b''' files on our machine.  
 
This will allow us to install '''d e b''' files on our machine.  
Line 204: Line 178:
 
'''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.  
Line 210: Line 183:
 
|| Highlight '''Setting up gdebi-core''' in the '''Terminal'''  
 
|| Highlight '''Setting up gdebi-core''' in the '''Terminal'''  
 
|| '''gdebi''' has been installed.  
 
|| '''gdebi''' has been installed.  
 
 
  
 
|-  
 
|-  
Line 223: Line 194:
 
'''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 '''deb''' 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'''.  
Line 229: Line 199:
 
|| 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'''
 
|| It will ask '''Do you want to install the software package? '''
 
|| It will ask '''Do you want to install the software package? '''
 
  
 
Press '''y''' to continue.  
 
Press '''y''' to continue.  
 
  
 
We will wait until the installation of '''RStudio''' is complete.  
 
We will wait until the installation of '''RStudio''' is complete.  
Line 238: Line 206:
 
|| Highlight '''Processing triggers''' in the '''Terminal'''
 
|| Highlight '''Processing triggers''' in the '''Terminal'''
 
|| '''RStudio''' has been installed.  
 
|| '''RStudio''' has been installed.  
 
 
  
 
|-  
 
|-  
Line 251: Line 217:
 
'''rstudio'''
 
'''rstudio'''
 
|| Now we will verify whether '''RStudio''' has been installed successfully.
 
|| Now we will verify whether '''RStudio''' has been installed successfully.
 
  
 
In the '''Terminal, '''type '''rstudio''' and press '''Enter'''.  
 
In the '''Terminal, '''type '''rstudio''' and press '''Enter'''.  
Line 283: Line 248:
 
* '''ggplot2''' and  
 
* '''ggplot2''' and  
 
* '''dplyr'''  
 
* '''dplyr'''  
 
  
 
|-  
 
|-  
Line 295: Line 259:
 
'''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.  
Line 309: Line 272:
 
'''Ctrl + L'''
 
'''Ctrl + L'''
 
|| Click in the '''Console''' window.  
 
|| Click in the '''Console''' window.  
 
  
 
Now, press''' Ctrl + '''L keys together.  
 
Now, press''' Ctrl + '''L keys together.  
Line 317: Line 279:
 
'''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.  
Line 334: Line 294:
 
'''Ctrl + L'''
 
'''Ctrl + L'''
 
|| Click in the '''Console''' window.  
 
|| Click in the '''Console''' window.  
 
  
 
Press''' Ctrl + '''L keys together.  
 
Press''' Ctrl + '''L keys together.  
Line 342: Line 301:
 
'''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.  
Line 354: Line 310:
 
|| Highlight '''DONE (ggplot2)''' in '''RStudio'''
 
|| Highlight '''DONE (ggplot2)''' in '''RStudio'''
 
|| '''ggplot2''' package is now installed.  
 
|| '''ggplot2''' package is now installed.  
 
 
  
 
|-  
 
|-  
Line 365: Line 319:
 
'''Ctrl + L'''
 
'''Ctrl + L'''
 
|| Click in the '''Console''' window.  
 
|| Click in the '''Console''' window.  
 
  
 
Press''' Ctrl + '''L keys together.  
 
Press''' Ctrl + '''L keys together.  
Line 373: Line 326:
 
'''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.  
Line 397: Line 347:
 
* Open '''RStudio''' interface
 
* Open '''RStudio''' interface
 
* Install packages
 
* Install packages
 
  
 
|-  
 
|-  
Line 417: Line 366:
  
 
Forum to answer questions
 
Forum to answer questions
 
 
  
 
|| Do you have questions in THIS '''Spoken Tutorial?'''
 
|| Do you have questions in THIS '''Spoken Tutorial?'''
Line 433: Line 380:
  
 
Forum to answer questions
 
Forum to answer questions
|| Do you have any general / technical questions?
+
|| Do you have any general/technical questions?
  
 
Please visit the forum given in the link.
 
Please visit the forum given in the link.
Line 441: Line 388:
 
Textbook Companion
 
Textbook Companion
 
|| The '''FOSSEE '''team coordinates coding of solved examples of popular books.
 
|| The '''FOSSEE '''team coordinates coding of solved examples of popular books.
 
  
 
We give honorarium and certificates to those who do this.
 
We give honorarium and certificates to those who do this.
Line 449: Line 395:
 
|| Show Slide
 
|| Show Slide
  
Acknowledgement
+
Acknowledgment
 
|| The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India
 
|| The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India
 
|-  
 
|-  

Revision as of 02:43, 28 September 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 slideSystem 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 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 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 wget command.

[Terminal]

sudo apt-get install -y g++ wget

Let us install the wget utility first.

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

We will wait until the installation of wget is complete.

Highlight Setting up wget in the Terminal wget 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 deb 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 gdebi has been installed.
[Terminal]

clear

I will clear the Terminal.
[Terminal]

sudo gdebi rstudio-1.1.463-amd64.deb

Now, we will install the deb 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
  • plyr
  • MASS
  • ggplot2 and
  • dplyr
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