From Script | Spoken-Tutorial
Jump to: navigation, search

Time Narration
00:01 Welcome to this tutorial on Introduction to R Studio.
00:06 In this tutorial, you will learn about these features of Rstudio:
00:13 Source and Console windows
00:15 Workspace; Plots and Files window
00:21 How to install packages of R
00:24 To understand this tutorial, you should know:
00:28 Elementary Maths
00:32 Basic commands of R
00:36 If not, please locate the relevant tutorials on R on this website.
00:41 This tutorial is recorded on
00:44 Ubuntu Linux Operating System 16.04
00:49 R version 3.2.3
00:52 RStudio version 1.1.456
00:58 Install R version 3.2.0 or higher.
01:04 Let us switch to Rstudio.
01:08 The window in the top left corner is the Source window.
01:14 It is used to edit a script and run it.
01:17 The window in the bottom left corner is the Console window.
01:23 It is used to install packages or to run a particular command.
01:28 The upper right window is the Workspace window.
01:32 It stores all the variables used during execution of commands under the Environment tab.
01:40 Place your cursor on the inside edges of all the windows.
01:46 A four-headed arrow symbol appears.
01:50 You can drag this to resize your windows for better visibility.
01:56 Let us declare some variables.
01:59 In the Console, type testSample (capital S) space less than symbol followed by hyphen space c.
02:11 Now, in parentheses, type 1 comma 2 comma 3 comma 4.
02:18 Press Enter to execute this line.
02:21 You can see the variable testSample in the Environment window.
02:28 The lower right window is the Plots and Files window.
02:33 The Files tab is used to keep track of Working Directories.
02:38 We will learn more about Working Directory later in this series.
02:43 The Plots tab shows all the graphical output.
02:46 Let us plot the variable testSample.
02:50 In the Console, type plot testSample capital S in parentheses. Press Enter.
02:59 You can now see the plot in the Plots window.
03:04 Let us look at the Environment window in the upper right corner.
03:09 We will clear this variable in this window.
03:12 At the top of the Environment window, click on the broom icon.
03:18 A Confirm Remove Objects window appears.
03:22 Ensure that the box Include hidden objects is checked and click on Yes.
03:30 Now, there is no variable in the Environment.
03:33 Click in the Plots window and click on the broom icon.
03:39 A Clear Plots text box appears.
03:44 The text reads, “Are you sure you want to clear all of the plots in the history?”
03:50 Click Yes.
03:52 Now, let us try plotting this variable again.
03:56 In the Console, again type plot testSample in parentheses as before.
04:04 Press Enter.
04:06 No plot is generated.
04:08 Instead, we see:
04:10 Error in plot(testSample) : object 'testSample' not found
04:16 It means that the variable testSample has been removed from our Workspace.
04:22 So, you should be careful with this broom icon in the Environment window.
04:27 Next to Environment, the History tab stores all our actions.
04:34 Here, we can see the lines that have been executed so far.
04:40 Let us declare two variables, firstVar and secondVar, which will be used later.
04:47 In the Console, type first capital V a r space less than symbol followed by hyphen space 6.
05:00 Press Enter.
05:02 Next, type second capital V a r space less than symbol followed by hyphen space 8. Press Enter.
05:14 Our Console window is filled with the previous commands.
05:18 We need to clean the Console before moving on.
05:23 Click in the Console window and press Ctrl+L together.
05:28 Clicking on the broom icon in the upper right corner of the Console will also clear it.
05:35 To see this icon, place the cursor under the maximizer button of the Console window.
05:42 You will see a hand symbol and the text, Clear Console Ctrl+L.
05:48 Packages in R
05:50 R packages are a collection of R functions, compiled code and sample data.
05:57 Stored under a directory called library in the R environment.
06:01 By default, R installs a set of packages
06:07 Let us switch back to RStudio.
06:10 Now click on the Environment tab again.
06:14 To see the list of R packages installed in your system, in the Console, type library parentheses.
06:22 Press Enter.
06:24 A tab named R packages available opens up in Source window.
06:30 Let us install a new package named MASS.
06:34 Please make sure that you are connected to the Internet.
06:39 In the Console window, type install dot packages.
06:44 Now, MASS inside double quotes in parentheses.
06:50 Press Enter.
06:54 We will need to wait until R installs the package.
06:59 There is another way to install a package. Let us install another package named ggplot2.
07:07 In the top menu bar of RStudio, click on the Tools button.
07:16 From the drop-down menu, select the Install Packages option.
07:21 In the Packages field, type the name of the package ggplot2
07:28 Ensure that Install dependencies box is checked and click on the Install button.
07:37 To load a package, we use library function and provide the package name as an argument.
07:46 We will load the MASS package now.
07:49 In the Console window, type library MASS in parentheses and press Enter.
07:57 Now we will use fractions function available in the MASS package.
08:04 In the Console window, type f r a c t.
08:10 RStudio shows the fractions option.
08:14 Press Enter to select it.
08:17 You can use this feature while typing commands.
08:21 Only remember that R is case-sensitive.
08:24 After fractions, type, in parentheses, firstVar division slash secondVar.
08:34 Press Enter.
08:36 You can see the reduced fraction ¾ in the Console.
08:41 In the Console, we can also type firstVar division slash secondVar.
08:48 It gives the result in decimal form.
08:52 This brings us to the end of this tutorial. Let us summarize.
08:58 We have learnt about, Source and Console windows. Source and Console windows
09:02 Workspace; Plots and Files window
09:04 How to install packages of R
09:08 The video at the following link summarises the Spoken Tutorial project.
09:12 Please download and watch it.
09:16 We conduct workshops using Spoken Tutorials and give certificates.
09:22 Please contact us.
09:24 Do you have questions in THIS Spoken Tutorial?
09:27 Choose the minute and second where you have the question.
09:31 Explain your question briefly.
09:33 Someone from the FOSSEE team will answer them.
09:35 Please visit this site.
09:38 Do you have any general / technical questions?
09:41 Please visit the forum given in the link.
09:45 The FOSSEE team coordinates coding of solved examples of popular books.
09:52 We give honorarium and certificates for those who do this.
09:57 For more details, please visit these sites.
10:01 The Spoken Tutorial project is funded by MHRD, Govt. of India
10:07 This script has been contributed by Shaik (FOSSEE Fellow 2018) and Sudhakar from FOSSEE project.
10:15 This is Vidhya Iyer from IIT Bombay signing off. Thanks for watching.

Contributors and Content Editors