Difference between revisions of "R/C2/Installing-R-and-RStudio-on-Linux/English"
Sudhakarst (Talk | contribs) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 19: | Line 19: | ||
|| In this tutorial, we will learn how to: | || In this tutorial, we will learn how to: | ||
− | * Install''' R '''version | + | * Install''' R '''version 3.4.4 |
− | * Install '''RStudio''' version | + | * Install '''RStudio''' version 1.1.463 on '''Linux''' OS |
* Open '''RStudio''' interface | * Open '''RStudio''' interface | ||
− | * Install packages | + | * Install '''packages''' |
|- | |- | ||
− | || Show | + | || Show slide |
+ | |||
+ | System Specifications | ||
+ | |||
|| To install '''R''' and '''RStudio''', I am using, | || To install '''R''' and '''RStudio''', I am using, | ||
− | * '''Ubuntu Linux '''OS version | + | * '''Ubuntu Linux '''OS version 16.04. |
− | * A working Internet connection. | + | * A working '''Internet''' connection. |
|- | |- | ||
Line 42: | Line 45: | ||
'''sudo apt-get install r-base''' | '''sudo apt-get install r-base''' | ||
− | || In the '''Terminal | + | || 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''' | ||
− | + | Type y to continue. | |
|| The installation for '''R''' begins. | || The installation for '''R''' begins. | ||
− | + | Type '''Y''' and press '''Enter''' to continue the installation process whenever prompted. | |
|- | |- | ||
|| Cursor on the '''Terminal'''. | || Cursor on the '''Terminal'''. | ||
Line 62: | Line 65: | ||
|- | |- | ||
|| Highlight processing triggers statements in the '''Terminal''' | || Highlight processing triggers statements in the '''Terminal''' | ||
− | || '''R''' is now | + | || '''R''' is now installed on our machine. |
|- | |- | ||
|| Cursor on the '''Terminal'''. | || Cursor on the '''Terminal'''. | ||
Line 69: | Line 72: | ||
In the '''Terminal''', type '''clear''' and press '''Enter'''. | In the '''Terminal''', type '''clear''' and press '''Enter'''. | ||
|- | |- | ||
− | || | + | || Cursor on the '''Terminal'''. |
|| Let us check if the installation of '''R''' is successful. | || Let us check if the installation of '''R''' is successful. | ||
|- | |- | ||
Line 87: | 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 94: | Line 97: | ||
'''exp(1)''' | '''exp(1)''' | ||
− | || We will compute the value of | + | || 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 103: | Line 108: | ||
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'''. |
|- | |- | ||
|| Highlight '''R version''' in the '''Terminal''' | || Highlight '''R version''' in the '''Terminal''' | ||
Line 111: | 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'''. |
|- | |- | ||
|| [Terminal] | || [Terminal] | ||
− | '''clear''' | + | '''clear''', Press '''Enter'''. |
|| I will clear the '''Terminal''' before moving further. | || I will clear the '''Terminal''' before moving further. | ||
Line 126: | Line 131: | ||
|- | |- | ||
|| Cursor on the terminal. | || Cursor on the terminal. | ||
− | || Now, we will install '''RStudio '''version | + | || Now, we will install '''RStudio '''version 1.1.463. |
− | For this, we need to download the corresponding '''d e b''' file using the ''' | + | 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 ''' | + | || 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 ''' | + | 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''' | ||
− | || ''' | + | || '''w get''' is now installed on the machine. |
|- | |- | ||
|| Cursor in the '''Terminal''' | || Cursor in the '''Terminal''' | ||
Line 148: | Line 153: | ||
'''cd ''' | '''cd ''' | ||
− | || We will change the working directory to ''' | + | || We will change the '''working directory''' to '''Home'''. |
− | In the '''Terminal''' | + | In the '''Terminal''', 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 | + | || Highlight '''rstudio-1.1.463-amd64.deb''' saved in the '''Terminal''' |
− | || The ''' | + | || The '''d e b''' file has been downloaded. |
|- | |- | ||
|| [Terminal] | || [Terminal] | ||
Line 177: | 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''' | ||
− | || ''' | + | || '''g d e b i''' has been installed. |
|- | |- | ||
Line 193: | Line 198: | ||
'''sudo gdebi rstudio-1.1.463-amd64.deb''' | '''sudo gdebi rstudio-1.1.463-amd64.deb''' | ||
− | || Now, we will install the ''' | + | || 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 211: | Line 216: | ||
'''clear''' | '''clear''' | ||
− | || I will clear the '''Terminal '''again. | + | || I will clear the '''Terminal''' again. |
|- | |- | ||
|| [Terminal] | || [Terminal] | ||
Line 224: | 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''' | + | || 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 238: | 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 244: | Line 251: | ||
Installing Packages | Installing Packages | ||
|| We will install | || We will install | ||
− | * ''' | + | * '''p l y r''' |
* '''MASS''' | * '''MASS''' | ||
* '''ggplot2''' and | * '''ggplot2''' and | ||
− | * ''' | + | * '''d p l y r''' |
|- | |- | ||
Line 258: | 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''' | + | || '''plyr package''' is now installed. |
|- | |- | ||
|| Cursor in the '''Console''' window of '''RStudio''' | || Cursor in the '''Console''' window of '''RStudio''' | ||
Line 273: | Line 280: | ||
|| Click in the '''Console''' window. | || Click in the '''Console''' window. | ||
− | Now, press''' Ctrl + '''L keys together. | + | Now, press '''Ctrl''' + '''L''' keys together. |
|- | |- | ||
|| [RStudio] | || [RStudio] | ||
'''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''' | + | || '''MASS package''' is now installed. |
|- | |- | ||
|| Cursor in the '''Console''' window of '''RStudio''' | || Cursor in the '''Console''' window of '''RStudio''' | ||
Line 292: | Line 299: | ||
|| [RStudio] | || [RStudio] | ||
− | '''Ctrl + L''' | + | '''Ctrl''' + '''L''' |
|| Click in the '''Console''' window. | || Click in the '''Console''' window. | ||
− | Press''' Ctrl + '''L keys together. | + | Press '''Ctrl''' + '''L''' keys together. |
|- | |- | ||
|| [RStudio] | || [RStudio] | ||
'''install.packages("ggplot2")''' | '''install.packages("ggplot2")''' | ||
− | || Now, we will install '''ggplot2 ''' | + | || 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''' | + | || '''ggplot2 package''' is now installed. |
|- | |- | ||
Line 317: | Line 324: | ||
|| [RStudio] | || [RStudio] | ||
− | '''Ctrl + L''' | + | '''Ctrl''' + '''L''' |
|| Click in the '''Console''' window. | || Click in the '''Console''' window. | ||
− | Press''' Ctrl + '''L keys together. | + | Press '''Ctrl''' + '''L''' keys together. |
|- | |- | ||
|| [RStudio] | || [RStudio] | ||
'''install.packages("dplyr")''' | '''install.packages("dplyr")''' | ||
− | || Now, we will install '''dplyr ''' | + | || 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''' | + | || '''dplyr package''' is now installed. |
|- | |- | ||
|| | || | ||
Line 343: | Line 350: | ||
Summary | Summary | ||
|| In this tutorial, we have learnt how to, | || In this tutorial, we have learnt how to, | ||
− | * Install''' R '''version | + | * Install''' R '''version 3.4.4 |
− | * Install '''RStudio''' version | + | * Install '''RStudio''' version 1.1.463 on '''Linux''' OS |
* Open '''RStudio''' interface | * Open '''RStudio''' interface | ||
− | * Install packages | + | * Install '''packages''' |
|- | |- |
Latest revision as of 13:04, 4 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:
|
Show slide
System Specifications |
To install R and RStudio, I am using,
|
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] | 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
|
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,
|
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. |