R/C2/Introduction-to-basics-of-R/English
FOSS: R through RStudio
R version 3.0.0 (2013-04-03) and RStudio version 0.97.336
Tutorial Title: Introduction to basics of R
Author: Kannan Moudgalya
Reviewer: Neeraj Hatekar, S. Subramanian, T. Santhanam, Sanjeev Bakshi, Revathi Kasturi and others
Date: 25 August 2013
Keywords: Video tutorial, spoken tutorial, introduction to R, introduction to RStudio, mathematical operations, creation of vectors, sine of a vector, plotting with R
Visual Cue | Narration |
---|---|
Slide 1
Opening slide |
Welcome to the spoken tutorial on basics of R.
|
Slide 2
Learning Objectives
|
In this tutorial, we hope to provide a feel for R and RStudio
|
Slide 3
Prerequisites
|
|
Slide 4
Systems Requirements
|
* I am using version 3 of R
|
Slide 5
System Requirements, ctnd. |
Let us continue with system requirements.
|
Slide 6
A Quick Introduction to R
|
Let us give a quick introduction to R:
|
Slide 7
A Quick Introduction to RStudio
|
Let us now give a quick introduction to RStudio
|
Show http://www.rstudio.com/ide | A two minute video by the RStudio team is available here. |
Slide 7 contd. | Let me return to the slides.
|
Slide 8
R, RStudio web server from Aakash |
Here is a screenshot of R and RStudio on a web server, accessed from Aakash |
Slide 9
Practice session on R, using RStudio |
Let us do a practice session on R, using RStudio
|
Show RStudio
|
You now see RStudio on the screen.
|
2.1 * 5
|
Let me begin multiplying two numbers two point one and five.
|
2.1 * 5 /3
|
I want to divide this by three.
|
2 + 3 | I can add two numbers. |
a <- 2 + 3
|
I can store the result in a variable using the assignment operator:
Less than symbol followed by hyphen. |
a = 2 + 3 | One can also use an equal sign. |
a
|
If I want to see what is in a variable, I just type the variable name.
|
a - 0.16 | I will subtract zero point one six from a. |
(a - 0.16) ^ 0.5
|
I will raise it to the power of zero point 5.
|
Using the left and right arrows, I moved the cursor back and forth within a command. | |
sqrt ( a - 0.16 ) | I can also carry out the same calculation using the function call, square root. |
exp(1)
|
I will find the value of e by using the function call, exp.
|
log ( exp(1))
|
I can find the natural logarithm of e with the help of the log function.
|
log10 ( 10^5 )
|
How do we find the log to the base ten?
|
log ( 10^5 )
|
What happens if I forget the ten in log10?
|
log (10^5,10)
|
There is another way to find the logarithm to the base of 10.
|
It is easy to create vectors in R. | |
z = seq (-1, 2, 0.5)
|
z = s e q -1 comma 2 comma 0.5
|
z | Let us see the value of z. |
We will see other ways to create vectors in another tutorial. | |
length (z)
|
We can calculate the length of the vector z using the command length.
|
We will now discuss pi. | |
pi
|
The value of pi, is stored in the variable pi, p i, which we can see now. |
x = seq (-2*pi, 2*pi, 1)
|
Let us create a vector x to start from minus two pi, go up to plus two pi, in increments of one.
|
x | Let us see what x contains |
y = sin(x)
|
Let us find the sine of this vector using sin and store it in y.
|
y | Let us see what y contains. |
plot (x, y, type=”l”)
|
Let us plot sin(x) versus x, with type=L argument added.
|
x = seq(-2*pi, 2*pi, 0.1) | Let us now get more points by lowering the increment number to point one. |
plot(x,y,type=”l”)
|
What happens if I try to plot without recalculating y?
|
y = sin(x) | Let me recalculate y. |
plot(x, y, type=”l”)
|
Let me re-plot this curve.
|
length(x)
length(y)
|
We see the lengths of x and y to be 126.
|
plot(x, y) | If we drop the type parameter in the previous command, we get a plot with points. |
Press help
|
Let us press the help button in the right hand side window.
|
We have come to the end of this tutorial. | |
Slide 10
Low cost books on R |
Let us see a few low cost books on R. |
Slide 11
Summary
|
In this tutorial we learnt about
|
Slide 12
Assignment
|
We now suggest an assignment
|
Slide 13
About the Spoken Tutorial Project
|
This video summarises the Spoken Tutorial project.
|
Slide 14
Spoken Tutorial Workshops
|
We conduct workshops using Spoken Tutorials.
|
Slide 15
Acknowledgements |
The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India |
Slide 16 Thanks | Thanks for joining, goodbye |