R/C2/Introduction-to-basics-of-R/English-timed

From Script | Spoken-Tutorial
Revision as of 11:54, 8 May 2020 by Sakinashaikh (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Welcome to the spoken tutorial on basics of R.
00:06 In this tutorial, we hope to provide a feel for R and Rstudio
00:11 How can R be used as a calculator?
00:14 How to use built-in functions like sin and log?
00:17 Introduction to vector operations
00:19 Introduction to plotting
00:21 Taking help in RStudio and
00:24 Where to get more information on R and Rstudio
00:28 To understand this tutorial, one needs to know elementary maths.
00:32 For example, log, sine and plotting
00:35 Please locate this tutorial on our website, spoken tutorial dot org
00:40 We provide many useful supplementary material in this page
00:44 No programming background is required, however, to understand this tutorial
00:50 I am using version 3 of R,Using RStudio 0.97
00:56 R and RStudio work on web browsers also
01:00 Hence, these are easily accessible from every operating system, including Aakash
01:07 Let us continue with system requirements.
01:09 For this tutorial, I am using Mac OS X 10.7.4
01:14 But the usage is similar in Linux and Windows as well
01:18 Let us give a quick introduction to R.
01:21 R is an outstanding software for general computations
01:24 It is especially suitable for statistical computing
01:27 It is an alternative to SPSS
01:30 It is a free and open source software
01:32 It can be downloaded from c ran dot r dash project dot org
01:39 Let us now give a quick introduction to Rstudio
01:42 RStudio is a friendly front-end to R
01:45 It is a free and open source software
01:48 It can be downloaded from rstudio dot com
01:51 A two minute video by the RStudio team is available here.
02:01 Let me return to the slides.
02:05 RStudio also runs on a web browser.
02:09 Here is a screenshot of R and RStudio on a web server, accessed from Aakash
02:15 Let us do a practice session on R, using Rstudio
02:21 You now see RStudio on the screen.
02:24 I have shrunk its size quite a bit, to fit into a small screen.
02:29 Please use a size you are comfortable with.
02:32 I have also enlarged the font size, so that the recording is clear.
02:36 You do this on Windows and Linux, by pressing control and + keys together.
02:41 For this tutorial, I want to maximise the size of the console of Rstudio.
02:48 I do this by pressing the maximise button in the console window.
02:54 I also maximise the right lower window of RStudio in a similar manner.
03:02 Let me begin multiplying two numbers two point one and five.
03:12 R gives the answer in black as ten point five.
03:16 I want to divide this by three.
03:18 I will recall the previous command by clicking the up arrow.
03:22 What I typed earlier, namely two point one into five appears.
03:26 I will divide this by three to get the answer three point five.
03:31 I can add two numbers.
03:35 I can store the result in a variable using the assignment operator.
03:42 Less than symbol followed by hyphen.
03:48 One can also use an equal sign.
03:53 If I want to see what is in a variable, I just type the variable name.
03:59 In this case, I type a and see that it has five.
04:03 I will subtract zero point one six from a.
04:11 I will raise it to the power of zero point 5.
04:15 Remember, I have to put a minus zero point one six within brackets, to get the correct answer.
04:26 We get two point two, as expected.
04:29 Using the left and right arrows, I moved the cursor back and forth within a command.
04:35 I can also carry out the same calculation using the function call, square root.
04:48 I will find the value of e by using the function call, exp.
04:55 You may have noticed, the moment I open a bracket, R automatically closes it.
05:01 This eliminates errors due to unmatched brackets. So, we see the value of e above.
05:08 I can find the natural logarithm of e with the help of the log function.
05:18 The value is one, as expected
05:22 How do we find the log to the base ten?
05:25 Use the command log10.
05:30 Ten to the power five.
05:36 This gives the answer as five, as expected.
05:40 What happens if I forget the ten in log10?
05:48 We get a different answer.
05:50 It is easy to verify that this answer is correct for natural logarithm.
05:54 Can you please suggest a method to verify this?
05:57 There is another way to find the logarithm to the base of 10.
06:04 Give the base as the second parameter, as I do here.
06:13 We get five, as expected.
06:16 It is easy to create vectors in R.
06:19 z = s e q -1 comma 2 comma 0:5
06:29 This creates a vector starting at minus one, going up to two, in increments of point five

s e q denotes sequence.

06:44 Let us see the value of z.
06:48 We will see other ways to create vectors in another tutorial.
06:53 We can calculate the length of the vector z using the command length:
07:01 We get the result seven, as expected.
07:07 We will now discuss pi.
07:09 The value of pi, is stored in the variable pi, p i, which we can see now.
07:16 Let us create a vector x to start from minus two pi, go up to plus two pi, in increments of one.
07:30 Please remember to put the multiply sign.
07:34 Let us see what x contains
07:38 Let us find the sine of this vector using sin and store it in y.
07:51 We can work directly with vectors in R, as we did above.
07:56 Let us see what y contains.
08:00 Let us plot sin(x) versus x, with type=L argument added.
08:12 Note that x comes first and then y.
08:17 This plot starts from zero as expected, because sin of minus two pi is zero.
08:24 The plot is not smooth, as there are not many points.
08:28 Let us now get more points by lowering the increment number to point one.
08:41 What happens if I try to plot without recalculating y?
08:46 R will complain that the lengths are unequal.
08:52 You should pause the video and confirm that the lengths are unequal.
08:57 Let me recalculate y.
09:00 Let me re-plot this curve.
09:05 You can see that the plot is smoother now.
09:08 Please pause the video now and look at the values stored in x and y.
09:13 Please confirm that these values are as per expectation.
09:18 We see the lengths of x and y to be 126.
09:28 You should verify that these lengths are correct.
09:31 You should also display the values of x and y and verify.
09:35 If we drop the type parameter in the previous command, we get a plot with points.
09:45 Let us press the help button in the right hand side window.
09:49 Let us type plot next to the lens symbol and hit return.
09:58 Let us scroll.
10:00 One can see different choices for the type parameter.
10:04 We have come to the end of this tutorial.
10:08 Let us see a few low cost books on R.
10:17 In this tutorial we learnt about, a few elementary operations
10:22 Introduction to plotting
10:24 Introduction to help
10:26 URLs and books on R and Rstudio
10:30 We now suggest an assignment
10:32 Find answers to log2 (2^5) and log (e^2)
10:39 Please explain your answers
10:41 Explore the Help tab in RStudio: Change the labels, title, etc.
10:47 Hint: try the plot command with x l a b argument
10:53 Copy paste a few examples provided in Help and see what they do
10:58 This video summarises the Spoken Tutorial project.
11:02 If you do not have good bandwidth, you may download and watch it.
11:06 We conduct workshops using Spoken Tutorials.
11:09 Give Certificates.
11:12 Please contact us.
11:15 The Spoken Tutorial project is funded by MHRD, Gov. of India
11:22 Thanks for joining, goodbye

Contributors and Content Editors

Sakinashaikh