Difference between revisions of "R/C2/Introduction-to-RStudio/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 7: Line 7:
  
 
{| style="border-spacing:0;width:7.3958in;"
 
{| style="border-spacing:0;width:7.3958in;"
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
| align=center| '''Visual Cue'''
+
| align=center style="background-color:#ffffff;border-top:1pt solid #000001;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | '''Visual Cue'''
| align=center| '''Narration'''
+
| align=center style="background-color:#ffffff;border:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | '''Narration'''
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
Opening slide
 
Opening slide
|| <span style="background-color:#ffffff;">Welcome to this tutorial on </span><span style="background-color:#ffffff;">'''Introduction to R Studio.'''</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Welcome to this tutorial on </span><span style="background-color:#ffffff;">'''Introduction to R Studio.'''</span>
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
Objectives
 
Objectives
|| In this tutorial,''' '''you will learn about these features of '''RStudio''':* <div style="margin-left:0.7665in;margin-right:0in;">'''Source '''and '''Console '''windows </div>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In this tutorial,''' '''you will learn about these features of '''RStudio''':* <div style="margin-left:0.7665in;margin-right:0in;">'''Source '''and '''Console '''windows </div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''Workspace; Plots '''and '''Files '''window</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''Workspace; Plots '''and '''Files '''window</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">How to install '''packages''' of '''R'''</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">How to install '''packages''' of '''R'''</div>
  
  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
Pre-requisites
 
Pre-requisites
Line 31: Line 31:
  
  
|| To understand this tutorial, you should know: * <div style="margin-left:0.7665in;margin-right:0in;">Elementary Maths </div>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | To understand this tutorial, you should know: * <div style="margin-left:0.7665in;margin-right:0in;">Elementary Maths </div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">Basic commands of''' R'''</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">Basic commands of''' R'''</div>
  
Line 37: Line 37:
  
 
If not, please locate the relevant tutorials on '''R''' on this website.
 
If not, please locate the relevant tutorials on '''R''' on this website.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
Systems requirements
 
Systems requirements
Line 44: Line 44:
  
  
|| This tutorial is recorded on* <div style="margin-left:0.7665in;margin-right:0in;">'''Ubuntu Linux OS 16.04''' </div>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | This tutorial is recorded on* <div style="margin-left:0.7665in;margin-right:0in;">'''Ubuntu Linux OS 16.04''' </div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''R '''version''' 3.2.3 '''</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''R '''version''' 3.2.3 '''</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''RStudio''' version''' 1.1.456'''</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''RStudio''' version''' 1.1.456'''</div>
Line 51: Line 51:
  
 
Install '''R''' version '''3.2.0''' or higher.
 
Install '''R''' version '''3.2.0''' or higher.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [RStudio]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [RStudio]
  
 
RStudio window  
 
RStudio window  
|| Let us switch to '''RStudio'''.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us switch to '''RStudio'''.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''Source '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''Source '''window
|| The window in the top left corner is the '''Source''' window.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The window in the top left corner is the '''Source''' window.  
  
  
 
It is used to edit a '''script''' and run it.
 
It is used to edit a '''script''' and run it.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''Console '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''Console '''window
|| The window in the bottom left corner is the '''Console''' window.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The window in the bottom left corner is the '''Console''' window.  
  
  
 
It is used to install '''packages''' or to run a particular '''command'''.
 
It is used to install '''packages''' or to run a particular '''command'''.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''Workspace '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''Workspace '''window
  
  
 
Highlight '''Environment''' tab
 
Highlight '''Environment''' tab
|| The upper right window is the '''Workspace''' window.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The upper right window is the '''Workspace''' window.  
  
  
 
It stores all the variables used during execution of commands under the '''Environment''' tab.
 
It stores all the variables used during execution of commands under the '''Environment''' tab.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Place cursor on the inside edges of all the windows.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Place cursor on the inside edges of all the windows.  
  
  
 
Point to the four-headed arrow.  
 
Point to the four-headed arrow.  
|| Place your cursor on the inside edges of all the windows.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Place your cursor on the inside edges of all the windows.  
  
  
 
A four-headed arrow symbol appears.  
 
A four-headed arrow symbol appears.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Drag this to resize windows for better visibility.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Drag this to resize windows for better visibility.  
|| You can drag this to resize your windows for better visibility.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | You can drag this to resize your windows for better visibility.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| Let us declare some variables.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us declare some variables.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Type '''testSample <- c(1,2,3,4)''' in '''Console'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Type '''testSample <- c(1,2,3,4)''' in '''Console'''
|| In the '''Console''', type '''testSample (capital S) '''space '''less than''' symbol followed by '''hyphen '''space '''c. '''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the '''Console''', type '''testSample (capital S) '''space '''less than''' symbol followed by '''hyphen '''space '''c. '''
  
  
Line 101: Line 101:
  
 
Press '''Enter''' to execute this line.  
 
Press '''Enter''' to execute this line.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''testSample''' in Environment tab
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''testSample''' in Environment tab
|| You can see the variable '''testSample''' in the '''Environment '''window.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | You can see the variable '''testSample''' in the '''Environment '''window.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''Plots '''and '''Files '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''Plots '''and '''Files '''window
|| The lower right window is the '''Plots '''and''' Files''' window.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The lower right window is the '''Plots '''and''' Files''' window.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''Files''' tab
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''Files''' tab
  
  
 
Highlight the '''Plots''' tab
 
Highlight the '''Plots''' tab
|| '''The Files''' tab is used to keep track of '''Working Directories'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | '''The Files''' tab is used to keep track of '''Working Directories'''.  
  
 
We will learn more about '''Working Directory''' later in this series.  
 
We will learn more about '''Working Directory''' later in this series.  
Line 118: Line 118:
  
 
The''' Plots''' tab shows all the '''graphical output'''.  
 
The''' Plots''' tab shows all the '''graphical output'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| Let us plot the variable '''testSample'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us plot the variable '''testSample'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Type '''plot(testSample)''' in the Console window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Type '''plot(testSample)''' in the Console window
  
  
 
Highlight the output plot  
 
Highlight the output plot  
|| In the '''Console''', type '''plot testSample capital S in parentheses. '''Press '''Enter'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the '''Console''', type '''plot testSample capital S in parentheses. '''Press '''Enter'''.  
  
  
 
You can now see the plot in the '''Plots '''window.
 
You can now see the plot in the '''Plots '''window.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the '''Environment '''tab
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the '''Environment '''tab
|| Let us look at the '''Environment '''window in the upper right corner.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us look at the '''Environment '''window in the upper right corner.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight '''testSample'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight '''testSample'''
  
  
 
Highlight broom-shaped icon in '''Environment '''
 
Highlight broom-shaped icon in '''Environment '''
|| We will clear this '''variable''' in this window.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | We will clear this '''variable''' in this window.  
  
  
 
At the top of the '''Environment''' window, click on the broom icon.  
 
At the top of the '''Environment''' window, click on the broom icon.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| In '''Confirm Remove Objects''' window >> check '''Include hidden objects''' >> click on '''Yes'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In '''Confirm Remove Objects''' window >> check '''Include hidden objects''' >> click on '''Yes'''
|| A '''Confirm Remove Objects''' window appears.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | A '''Confirm Remove Objects''' window appears.  
  
  
 
Ensure that the box '''Include hidden objects''' is checked and click on '''Yes'''.  
 
Ensure that the box '''Include hidden objects''' is checked and click on '''Yes'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight '''Environment '''tab
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight '''Environment '''tab
|| Now, there is no '''variable '''in the '''Environment'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Now, there is no '''variable '''in the '''Environment'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Click in the '''Plots '''window and click on the broom icon.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Click in the '''Plots '''window and click on the broom icon.  
|| Click in the '''Plots '''window and click on the broom icon.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Click in the '''Plots '''window and click on the broom icon.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Point to Clear Plots text box.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Point to Clear Plots text box.
|| A Clear Plots text box appears.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | A Clear Plots text box appears.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Point to Clear Plots text box.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Point to Clear Plots text box.
|| The text reads, “Are you sure you want to clear all of the plots in the history?”
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The text reads, “Are you sure you want to clear all of the plots in the history?”
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Click Yes.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Click Yes.  
|| Click Yes.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Click Yes.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Type plot('''testSample''') in the '''Console '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Type plot('''testSample''') in the '''Console '''window
|| Now, let us try plotting this variable again.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Now, let us try plotting this variable again.  
  
  
Line 171: Line 171:
  
 
Press '''Enter'''.  
 
Press '''Enter'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the error in the '''Console '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the error in the '''Console '''window
  
  
 
Highlight broom-shaped icon in '''Environment '''
 
Highlight broom-shaped icon in '''Environment '''
|| No plot is generated.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | No plot is generated.  
  
  
Line 188: Line 188:
  
 
So, you should be careful with this broom icon in the '''Environment '''window.  
 
So, you should be careful with this broom icon in the '''Environment '''window.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
  
 
'''History '''tab  
 
'''History '''tab  
Line 195: Line 195:
  
 
Highlight the commands
 
Highlight the commands
|| Next to '''Environment''', the '''History''' tab stores all our actions.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Next to '''Environment''', the '''History''' tab stores all our actions.
  
 
Here, we can see the lines that have been executed so far.  
 
Here, we can see the lines that have been executed so far.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| Let us declare two variables, '''firstVar''' and '''secondVar''', which will be used later.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us declare two variables, '''firstVar''' and '''secondVar''', which will be used later.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [Console]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [Console]
  
  
Line 208: Line 208:
  
 
Type '''secondVar <- 8'''
 
Type '''secondVar <- 8'''
|| In the Console, type '''first capital V a r '''space '''less than''' symbol followed by '''hyphen '''space 6.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the Console, type '''first capital V a r '''space '''less than''' symbol followed by '''hyphen '''space 6.  
  
  
Line 217: Line 217:
  
 
Press '''Enter'''.  
 
Press '''Enter'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [RStudio]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [RStudio]
  
 
Press '''Ctrl+L'''
 
Press '''Ctrl+L'''
|| Our '''Console '''window is filled with the previous '''commands'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Our '''Console '''window is filled with the previous '''commands'''.  
  
 
We need to clean the '''Console''' before moving on.  
 
We need to clean the '''Console''' before moving on.  
  
 
Click in the '''Console''' window and press '''Ctrl+L together. '''
 
Click in the '''Console''' window and press '''Ctrl+L together. '''
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Highlight the broom-shaped icon at the right corner of the '''Console '''window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Highlight the broom-shaped icon at the right corner of the '''Console '''window
|| Clicking on the''' '''broom icon in the upper right corner of the '''Console''' will also clear it.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Clicking on the''' '''broom icon in the upper right corner of the '''Console''' will also clear it.
  
 
To see this icon, place the cursor under the maximizer button of the '''Console '''window.  
 
To see this icon, place the cursor under the maximizer button of the '''Console '''window.  
  
 
You will see a hand symbol and the text, '''Clear Console Ctrl+L'''.  
 
You will see a hand symbol and the text, '''Clear Console Ctrl+L'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide  
  
 
Packages in R  
 
Packages in R  
|| <span style="background-color:#ffffff;">'''R packages'''</span><span style="background-color:#ffffff;"> are </span>* <div style="margin-left:0.7665in;margin-right:0in;">A collection of''' R functions, compiled code '''and sample data</div>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">'''R packages'''</span><span style="background-color:#ffffff;"> are </span>* <div style="margin-left:0.7665in;margin-right:0in;">A collection of''' R functions, compiled code '''and sample data</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">Stored under a directory called '''library '''in the '''R environment'''.</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">Stored under a directory called '''library '''in the '''R environment'''.</div>
  
Line 243: Line 243:
  
 
<span style="background-color:#ffffff;">By default, </span><span style="background-color:#ffffff;">'''R'''</span><span style="background-color:#ffffff;"> installs a set of </span><span style="background-color:#ffffff;">'''packages'''</span><span style="background-color:#ffffff;">.</span>
 
<span style="background-color:#ffffff;">By default, </span><span style="background-color:#ffffff;">'''R'''</span><span style="background-color:#ffffff;"> installs a set of </span><span style="background-color:#ffffff;">'''packages'''</span><span style="background-color:#ffffff;">.</span>
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| Let us switch back to '''RStudio. '''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us switch back to '''RStudio. '''
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Click on the Environment tab again.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Click on the Environment tab again.  
|| Now click on the Environment tab again.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Now click on the Environment tab again.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [RStudio]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [RStudio]
  
 
Type '''library()'''
 
Type '''library()'''
|| To see the list of '''R packages''' installed in your system, type '''library parentheses''' in the '''Console.'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | To see the list of '''R packages''' installed in your system, type '''library parentheses''' in the '''Console.'''
  
 
Press '''Enter'''.  
 
Press '''Enter'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Tab '''R packages available '''opens in '''Source''' window
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Tab '''R packages available '''opens in '''Source''' window
|| A tab named '''R packages available '''opens up in '''Source''' window.''' '''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | A tab named '''R packages available '''opens up in '''Source''' window.''' '''
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| Let us install a new package named '''MASS'''. Please make sure that you are connected to the '''Internet'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Let us install a new package named '''MASS'''. Please make sure that you are connected to the '''Internet'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [Console]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [Console]
  
 
Type '''install.packages(<span style="background-color:#ffffff;">"MASS"</span>)'''  
 
Type '''install.packages(<span style="background-color:#ffffff;">"MASS"</span>)'''  
  
 
Highlight the red dot at the right corner of '''Console'''
 
Highlight the red dot at the right corner of '''Console'''
|| In the '''Console '''window, type '''install dot packages'''.''' '''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the '''Console '''window, type '''install dot packages'''.''' '''
  
 
Now''', MASS '''inside double quotes in parentheses.''' '''
 
Now''', MASS '''inside double quotes in parentheses.''' '''
Line 275: Line 275:
  
 
We will need to wait until '''R''' installs the '''package'''.  
 
We will need to wait until '''R''' installs the '''package'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| There is another way to install a '''package'''. Let us install another package named '''ggplot2'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | There is another way to install a '''package'''. Let us install another package named '''ggplot2'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Click on the '''Tools''' button >>  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Click on the '''Tools''' button >>  
  
 
Select the '''Install Packages''' option  
 
Select the '''Install Packages''' option  
|| In the top menu bar of '''RStudio, '''click on the '''Tools''' button.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the top menu bar of '''RStudio, '''click on the '''Tools''' button.  
  
 
From the dropdown menu, select the '''Install Packages''' option.  
 
From the dropdown menu, select the '''Install Packages''' option.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| In '''Packages''', type '''ggplot2'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In '''Packages''', type '''ggplot2'''
|| In the '''Packages''' field, type the name of the '''package''' '''ggplot2'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the '''Packages''' field, type the name of the '''package''' '''ggplot2'''
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Check the box '''Install dependencies''' >> click on the '''Install '''button
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Check the box '''Install dependencies''' >> click on the '''Install '''button
|| Ensure that '''Install dependencies''' box is checked and click on the '''Install''' button.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Ensure that '''Install dependencies''' box is checked and click on the '''Install''' button.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [RStudio]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [RStudio]
  
 
Type '''library(MASS) '''in the Console window  
 
Type '''library(MASS) '''in the Console window  
|| To load a '''package''', we use '''library() function '''and provide the '''package''' name as an '''argument'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | To load a '''package''', we use '''library() function '''and provide the '''package''' name as an '''argument'''.  
  
 
We will load the''' MASS package''' now.  
 
We will load the''' MASS package''' now.  
  
 
In the '''Console '''window, type '''library MASS in parentheses '''and press '''Enter'''.  
 
In the '''Console '''window, type '''library MASS in parentheses '''and press '''Enter'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| Now we will use '''fractions() function''' available in the '''MASS package'''.  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Now we will use '''fractions() function''' available in the '''MASS package'''.  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| [RStudio]
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | [RStudio]
  
  
Line 312: Line 312:
  
 
Press Enter to select.  
 
Press Enter to select.  
 
 
 
 
 
 
 
  
 
'''fractions(firstVar/secondVar)'''
 
'''fractions(firstVar/secondVar)'''
 
  
 
Highlight '''¾''' in the '''Console '''
 
Highlight '''¾''' in the '''Console '''
  
  
 
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
||  
+
 
+
  
  
Line 344: Line 334:
  
 
'''After fractions, type, in parentheses, firstVar division slash secondVar. '''
 
'''After fractions, type, in parentheses, firstVar division slash secondVar. '''
 
 
 
  
 
Press '''Enter'''.
 
Press '''Enter'''.
 
  
 
You can see the reduced fraction '''¾''' in the '''Console. '''
 
You can see the reduced fraction '''¾''' in the '''Console. '''
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Type '''firstVar/secondVar''' in the '''Console'''
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Type '''firstVar/secondVar''' in the '''Console'''
  
  
 
Highlight the output in decimal
 
Highlight the output in decimal
|| In the '''Console''', we can also type '''firstVar division slash secondVar'''.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | In the '''Console''', we can also type '''firstVar division slash secondVar'''.
 
+
  
 
It gives the result in decimal form.
 
It gives the result in decimal form.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
||  
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" |  
|| This brings us to the end of this tutorial. Let us summarize.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | This brings us to the end of this tutorial. Let us summarize.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
Summary
 
Summary
  
  
 
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | We have learned about, * <div style="margin-left:0.7665in;margin-right:0in;">'''Source '''and '''Console '''windows </div>
|| We have learned about, * <div style="margin-left:0.7665in;margin-right:0in;">'''Source '''and '''Console '''windows </div>
+
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''Workspace; Plots '''and '''Files '''window</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">'''Workspace; Plots '''and '''Files '''window</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">How to install '''packages''' of '''R'''</div>
 
* <div style="margin-left:0.7665in;margin-right:0in;">How to install '''packages''' of '''R'''</div>
  
 
+
|-
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
|| Show slide
+
  
 
Assignment
 
Assignment
|| We now suggest an assignment.* <div style="margin-left:0.7665in;margin-right:0in;">Install '''plyr package''' and load it.</div>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | We now suggest an assignment.* <div style="margin-left:0.7665in;margin-right:0in;">Install '''plyr package''' and load it.</div>
  
  
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
About the Spoken Tutorial Project
 
About the Spoken Tutorial Project
|| The video at the following link summarises the Spoken Tutorial project.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The video at the following link summarises the Spoken Tutorial project.
  
 
Please download and watch it.
 
Please download and watch it.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| Show slide
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | Show slide
  
 
Spoken Tutorial Workshops
 
Spoken Tutorial Workshops
|| We conduct workshops using Spoken Tutorials and give certificates.
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | We conduct workshops using Spoken Tutorials and give certificates.
  
 
Please contact us.
 
Please contact us.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| <span style="background-color:#ffffff;">Show Slide</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Show Slide</span>
  
 
Forum to answer questions
 
Forum to answer questions
Line 404: Line 387:
  
  
|| <span style="background-color:#ffffff;">Do you have questions in THIS </span><span style="background-color:#ffffff;">'''Spoken Tutorial?'''</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Do you have questions in THIS </span><span style="background-color:#ffffff;">'''Spoken Tutorial?'''</span>
  
 
Choose the minute and second where you have the question.
 
Choose the minute and second where you have the question.
Line 413: Line 396:
  
 
Please visit this site.
 
Please visit this site.
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| <span style="background-color:#ffffff;">Show Slide</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Show Slide</span>
  
 
Forum to answer questions
 
Forum to answer questions
|| <span style="background-color:#ffffff;">Do you have any general / technical questions?</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Do you have any general / technical questions?</span>
  
 
<span style="background-color:#ffffff;">Please visit the forum given in the link.</span>
 
<span style="background-color:#ffffff;">Please visit the forum given in the link.</span>
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| <span style="background-color:#ffffff;">Show Slide</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Show Slide</span>
  
 
<span style="background-color:#ffffff;">Textbook Companion</span>
 
<span style="background-color:#ffffff;">Textbook Companion</span>
|| <span style="background-color:#ffffff;">The </span><span style="background-color:#ffffff;">'''FOSSEE '''</span><span style="background-color:#ffffff;">team coordinates coding of solved examples of popular books.</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">The </span><span style="background-color:#ffffff;">'''FOSSEE '''</span><span style="background-color:#ffffff;">team coordinates coding of solved examples of popular books.</span>
  
 
<span style="background-color:#ffffff;">We give honorarium and certificates for those who do this.</span>
 
<span style="background-color:#ffffff;">We give honorarium and certificates for those who do this.</span>
  
 
<span style="background-color:#ffffff;">For more details, please visit these sites.</span>
 
<span style="background-color:#ffffff;">For more details, please visit these sites.</span>
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| <span style="background-color:#ffffff;">Show Slide</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Show Slide</span>
  
 
Acknowledgement
 
Acknowledgement
|| The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India
|- style="background-color:#ffffff;border:0.75pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;"
+
|-
|| <span style="background-color:#ffffff;">Show Slide</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:none;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">Show Slide</span>
  
 
Thank You
 
Thank You
|| <span style="background-color:#ffffff;">This script has been contributed by Shaik (FOSSEE Fellow 2018) and Sudhakar from FOSSEE project.</span>
+
| style="background-color:#ffffff;border-top:none;border-bottom:1pt solid #000001;border-left:1pt solid #000001;border-right:1pt solid #000001;padding-top:0in;padding-bottom:0in;padding-left:0.0743in;padding-right:0.075in;" | <span style="background-color:#ffffff;">This script has been contributed by Shaik (FOSSEE Fellow 2018) and Sudhakar from FOSSEE project.</span>
  
  

Revision as of 13:10, 16 November 2018

Title of script: Introduction to R Studio
Authors: Shaik Sameer (IIIT Vadodara) and Sudhakar Kumar (IIT Bombay)
Keywords: R, RStudio, workspace, console, packages


Visual Cue Narration
Show slide

Opening slide

Welcome to this tutorial on Introduction to R Studio.
Show slide

Objectives

In this tutorial, you will learn about these features of RStudio:*
Source and Console windows
  • Workspace; Plots and Files window
  • How to install packages of R


Show slide

Pre-requisites


To understand this tutorial, you should know: *
Elementary Maths
  • Basic commands of R


If not, please locate the relevant tutorials on R on this website.

Show slide

Systems requirements


This tutorial is recorded on*
Ubuntu Linux OS 16.04
  • R version 3.2.3
  • RStudio version 1.1.456


Install R version 3.2.0 or higher.

[RStudio]

RStudio window

Let us switch to RStudio.
Highlight the Source window The window in the top left corner is the Source window.


It is used to edit a script and run it.

Highlight the Console window The window in the bottom left corner is the Console window.


It is used to install packages or to run a particular command.

Highlight the Workspace window


Highlight Environment tab

The upper right window is the Workspace window.


It stores all the variables used during execution of commands under the Environment tab.

Place cursor on the inside edges of all the windows.


Point to the four-headed arrow.

Place your cursor on the inside edges of all the windows.


A four-headed arrow symbol appears.

Drag this to resize windows for better visibility. You can drag this to resize your windows for better visibility.
Let us declare some variables.
Type testSample <- c(1,2,3,4) in Console In the Console, type testSample (capital S) space less than symbol followed by hyphen space c.


Now, in parentheses, type 1 comma 2 comma 3 comma 4.


Press Enter to execute this line.

Highlight the testSample in Environment tab You can see the variable testSample in the Environment window.
Highlight the Plots and Files window The lower right window is the Plots and Files window.
Highlight the Files tab


Highlight the Plots tab

The Files tab is used to keep track of Working Directories.

We will learn more about Working Directory later in this series.


The Plots tab shows all the graphical output.

Let us plot the variable testSample.
Type plot(testSample) in the Console window


Highlight the output plot

In the Console, type plot testSample capital S in parentheses. Press Enter.


You can now see the plot in the Plots window.

Highlight the Environment tab Let us look at the Environment window in the upper right corner.
Highlight testSample


Highlight broom-shaped icon in Environment

We will clear this variable in this window.


At the top of the Environment window, click on the broom icon.

In Confirm Remove Objects window >> check Include hidden objects >> click on Yes A Confirm Remove Objects window appears.


Ensure that the box Include hidden objects is checked and click on Yes.

Highlight Environment tab Now, there is no variable in the Environment.
Click in the Plots window and click on the broom icon. Click in the Plots window and click on the broom icon.
Point to Clear Plots text box. A Clear Plots text box appears.
Point to Clear Plots text box. The text reads, “Are you sure you want to clear all of the plots in the history?”
Click Yes. Click Yes.
Type plot(testSample) in the Console window Now, let us try plotting this variable again.


In the Console, again type plot testSample in parentheses as before.

Press Enter.

Highlight the error in the Console window


Highlight broom-shaped icon in Environment

No plot is generated.


Instead, we see:

Error in plot(testSample) : object 'testSample' not found


It means that the variable testSample has been removed from our Workspace.


So, you should be careful with this broom icon in the Environment window.

History tab


Highlight the commands

Next to Environment, the History tab stores all our actions.

Here, we can see the lines that have been executed so far.

Let us declare two variables, firstVar and secondVar, which will be used later.
[Console]


Type firstVar <- 6

Type secondVar <- 8

In the Console, type first capital V a r space less than symbol followed by hyphen space 6.


Press Enter.


Next, type second capital V a r space less than symbol followed by hyphen space 8.

Press Enter.

[RStudio]

Press Ctrl+L

Our Console window is filled with the previous commands.

We need to clean the Console before moving on.

Click in the Console window and press Ctrl+L together.

Highlight the broom-shaped icon at the right corner of the Console window Clicking on the broom icon in the upper right corner of the Console will also clear it.

To see this icon, place the cursor under the maximizer button of the Console window.

You will see a hand symbol and the text, Clear Console Ctrl+L.

Show slide

Packages in R

R packages are *
A collection of R functions, compiled code and sample data
  • Stored under a directory called library in the R environment.


By default, R installs a set of packages.

Let us switch back to RStudio.
Click on the Environment tab again. Now click on the Environment tab again.
[RStudio]

Type library()

To see the list of R packages installed in your system, type library parentheses in the Console.

Press Enter.

Tab R packages available opens in Source window A tab named R packages available opens up in Source window.
Let us install a new package named MASS. Please make sure that you are connected to the Internet.
[Console]

Type install.packages("MASS")

Highlight the red dot at the right corner of Console

In the Console window, type install dot packages.

Now, MASS inside double quotes in parentheses.

Press Enter.

We will need to wait until R installs the package.

There is another way to install a package. Let us install another package named ggplot2.
Click on the Tools button >>

Select the Install Packages option

In the top menu bar of RStudio, click on the Tools button.

From the dropdown menu, select the Install Packages option.

In Packages, type ggplot2 In the Packages field, type the name of the package ggplot2
Check the box Install dependencies >> click on the Install button Ensure that Install dependencies box is checked and click on the Install button.
[RStudio]

Type library(MASS) in the Console window

To load a package, we use library() function and provide the package name as an argument.

We will load the MASS package now.

In the Console window, type library MASS in parentheses and press Enter.

Now we will use fractions() function available in the MASS package.
[RStudio]


Type f r a c t i o.

Point to the fractions option.

Press Enter to select.

fractions(firstVar/secondVar)

Highlight ¾ in the Console



In the Console window, type f r a c t i o.

RStudio shows the fractions option.

Press Enter to select it.


You can use this feature while typing commands.

Only remember that R is case-sensitive.


After fractions, type, in parentheses, firstVar division slash secondVar.

Press Enter.

You can see the reduced fraction ¾ in the Console.

Type firstVar/secondVar in the Console


Highlight the output in decimal

In the Console, we can also type firstVar division slash secondVar.

It gives the result in decimal form.

This brings us to the end of this tutorial. Let us summarize.
Show slide

Summary


We have learned about, *
Source and Console windows
  • Workspace; Plots and Files window
  • How to install packages of R
Show slide

Assignment

We now suggest an assignment.*
Install plyr package and load it.


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 for those who do this.

For more details, please visit these sites.

Show Slide

Acknowledgement

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

Thank You

This script has been contributed by Shaik (FOSSEE Fellow 2018) and Sudhakar from FOSSEE project.


This is Vidhya Iyer from IIT Bombay signing off. Thanks for watching.

Contributors and Content Editors

Nancyvarkey, Sudhakarst