R/C2/Introduction-to-RStudio/English
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
|
Show slide
Pre-requisites
|
To understand this tutorial, you should know: * Elementary Maths
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
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.
|
Highlight the Console window | The window in the bottom left corner is the Console window.
|
Highlight the Workspace window
|
The upper right window is the Workspace window.
|
Place cursor on the inside edges of all the windows.
|
Place your cursor on the inside edges of all the windows.
|
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.
|
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
|
The Files tab is used to keep track of Working Directories.
We will learn more about Working Directory later in this series.
|
Let us plot the variable testSample. | |
Type plot(testSample) in the Console window
|
In the Console, type plot testSample capital S in parentheses. Press Enter.
|
Highlight the Environment tab | Let us look at the Environment window in the upper right corner. |
Highlight testSample
|
We will clear this variable in this window.
|
In Confirm Remove Objects window >> check Include hidden objects >> click on Yes | A Confirm Remove Objects window appears.
|
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.
Press Enter. |
Highlight the error in the Console window
|
No plot is generated.
Error in plot(testSample) : object 'testSample' not found
|
History tab
|
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 secondVar <- 8 |
In the Console, type first capital V a r space less than symbol followed by hyphen space 6.
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
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]
Point to the fractions option. Press Enter to select. fractions(firstVar/secondVar) Highlight ¾ in the Console
|
RStudio shows the fractions option. Press Enter to select it.
Only remember that R is case-sensitive.
Press Enter. You can see the reduced fraction ¾ in the Console. |
Type firstVar/secondVar in the Console
|
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
|
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.
|