Difference between revisions of "R/C2/Introduction-to-basics-of-R/English"
Nancyvarkey (Talk | contribs) (Created page with ''''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 ''…') |
Sudhakarst (Talk | contribs) |
||
Line 31: | Line 31: | ||
Learning Objectives | Learning Objectives | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
| In this tutorial, we hope to provide a feel for '''R''' and '''RStudio''' | | In this tutorial, we hope to provide a feel for '''R''' and '''RStudio''' | ||
Line 52: | Line 45: | ||
Prerequisites | Prerequisites | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
| | | | ||
* To understand this tutorial, one needs to know elementary maths. | * To understand this tutorial, one needs to know elementary maths. | ||
Line 71: | Line 56: | ||
Systems Requirements | Systems Requirements | ||
− | |||
− | |||
− | |||
| * I am using version '''3''' of '''R''' | | * I am using version '''3''' of '''R''' | ||
Line 93: | Line 75: | ||
A Quick Introduction to R | A Quick Introduction to R | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
| Let us give a quick introduction to '''R''': | | Let us give a quick introduction to '''R''': | ||
Line 139: | Line 115: | ||
Practice session on R, using RStudio | Practice session on R, using RStudio | ||
| Let us do a practice session on '''R''', using '''RStudio''' | | Let us do a practice session on '''R''', using '''RStudio''' | ||
− | |||
|- | |- | ||
| Show RStudio | | Show RStudio | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
| You now see '''RStudio''' on the screen. | | You now see '''RStudio''' on the screen. | ||
Line 194: | Line 145: | ||
|- | |- | ||
|2.1 * 5 | |2.1 * 5 | ||
− | |||
− | |||
− | |||
|Let me begin multiplying two numbers two point one and five. | |Let me begin multiplying two numbers two point one and five. | ||
Line 204: | Line 152: | ||
|- | |- | ||
|2.1 * 5 /3 | |2.1 * 5 /3 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|I want to divide this by three. | |I want to divide this by three. | ||
Line 236: | Line 170: | ||
|- | |- | ||
|<nowiki>a <- 2 + 3</nowiki> | |<nowiki>a <- 2 + 3</nowiki> | ||
− | |||
− | |||
|I can store the result in a '''variable''' using the assignment operator: | |I can store the result in a '''variable''' using the assignment operator: | ||
Line 249: | Line 181: | ||
|- | |- | ||
|a | |a | ||
− | |||
− | |||
Line 264: | Line 194: | ||
|- | |- | ||
|(a - 0.16) ^ 0.5 | |(a - 0.16) ^ 0.5 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|I will raise it to the power of zero point 5. | |I will raise it to the power of zero point 5. | ||
Line 294: | Line 213: | ||
|- | |- | ||
|exp(1) | |exp(1) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|I will find the value of '''e''' by using the '''function call, exp'''. | |I will find the value of '''e''' by using the '''function call, exp'''. | ||
Line 317: | Line 227: | ||
|- | |- | ||
|log ( exp(1)) | |log ( exp(1)) | ||
− | |||
− | |||
− | |||
Line 329: | Line 236: | ||
|- | |- | ||
|log10 ( 10^5 ) | |log10 ( 10^5 ) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|How do we find the '''log to the base ten'''? | |How do we find the '''log to the base ten'''? | ||
Line 352: | Line 250: | ||
|- | |- | ||
|log ( 10^5 ) | |log ( 10^5 ) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|What happens if I forget the ten in '''log10'''? | |What happens if I forget the ten in '''log10'''? | ||
Line 375: | Line 264: | ||
|- | |- | ||
|log (10^5,10) | |log (10^5,10) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 397: | Line 280: | ||
|- | |- | ||
|z = seq (-1, 2, 0.5) | |z = seq (-1, 2, 0.5) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 423: | Line 300: | ||
|- | |- | ||
|length (z) | |length (z) | ||
− | |||
− | |||
Line 437: | Line 312: | ||
|- | |- | ||
|pi | |pi | ||
− | |||
Line 444: | Line 318: | ||
|- | |- | ||
|x = seq (-2*pi, 2*pi, 1) | |x = seq (-2*pi, 2*pi, 1) | ||
− | |||
− | |||
− | |||
− | |||
Line 461: | Line 331: | ||
|- | |- | ||
|y = sin(x) | |y = sin(x) | ||
− | |||
− | |||
Line 476: | Line 344: | ||
|- | |- | ||
|plot (x, y, type=”l”) | |plot (x, y, type=”l”) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 505: | Line 363: | ||
|- | |- | ||
|plot(x,y,type=”l”) | |plot(x,y,type=”l”) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 527: | Line 379: | ||
|- | |- | ||
|plot(x, y, type=”l”) | |plot(x, y, type=”l”) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 554: | Line 396: | ||
length(y) | length(y) | ||
− | |||
− | |||
− | |||
− | |||
Line 575: | Line 413: | ||
|- | |- | ||
|Press help | |Press help | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|Let us press the '''help button''' in the right hand side window. | |Let us press the '''help button''' in the right hand side window. | ||
Line 611: | Line 439: | ||
'''Summary''' | '''Summary''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 628: | Line 451: | ||
'''Assignment''' | '''Assignment''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|We now suggest an assignment | |We now suggest an assignment | ||
Line 662: | Line 475: | ||
Spoken Tutorial Workshops | Spoken Tutorial Workshops | ||
− | |||
− | |||
− | |||
|We conduct workshops using Spoken Tutorials. | |We conduct workshops using Spoken Tutorials. |
Revision as of 16:28, 24 April 2019
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 |