Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is the first lesson of CloudStat School, Lesson 1: Overview of R Language & CloudStat School.

The objective of this lesson is introducing R Language and how you can be a R programmer or a data analyst through CloudStat School.

At the end of this lesson 1, you will learn:

1. What and Why is R Language.
2. How to run CloudStat Console.
3. Use CloudStat Console as a calculator.
4. Some built-in mathematical functions.
5. Integer Quotients and Modulo.
6. Rounding (Up, down and nearest)

1. Introduction
1.1 What is CloudStat School?
An online platform for you to learn and do data analysis
with R Language collaboratively and interactively.

1.2 What is R Language?
R is an open source (free!) programming language
that has excellent statistical abilities.
R has Everything you need in terms of data analysis.

1.3 Prerequisites & Preparations
All you need is Internet Access! That’s all!

R is a language, like Italian, Dutch, Spanish, English, or Chinese.
If you try to proceed too rapidly, use the wrong reading material, or
have the wrong teacher, then, yes, mastering R may be challenging.
So be fun and enjoy the learning process!

1.5 Overview
You will see a console box at your left hand side.
Below is the output box. Anything you “Run”
in console box will be shown as a result in the output box.

There is a default command in the console box:
x = -100:100; plot(x^2)
Now, give it a try, just click “Run” to see what’s happening!

Yes! You’re plotting a quadratic function, x2 graph as below! Let’s try some more.
Use this console as a calculator! Type:
1+1

And click the “Run” button.
Simple math. 1+1 is 2. You will see something like:
> 1+1
 2

Try more:

12+43
56-12
5*6
63/7

“Run” it!

You will get:
> 12+43
 55
> 56-12
 44
> 5*6
 30
> 63/7
 9

Let’s do it in one line.
Just remember separate them with semi-colons ;

12+43; 56-12; 5*6; 63/7

Then, click “Run” button to see the result.

You will see something like:

> 12+43; 56-12; 5*6; 63/7
 55
 44
 30
 9

Let’s try some built-in mathematical functions!

exp(12)
log(12)
sin(12)

Then, click “Run” button as before to see the output!

You will see

> exp(12)
 162754.8
> log(12)
 2.484907
> sin(12)
 -0.5365729

There are more! You can try:
log(x) = log to base e of x
exp(x) = antilog of x ex
log(x,n) = log to base n of x
log10(x) = log to base 10 of x
sqrt(x) = square root of x
cos(x) = cosine of x in radians
atan(x) = inverse trigonometric transformations
More…

Want to use π ? Please type:

pi

Output will be:

> pi
 3.141593

Type:
cos(pi/2)

You will get:
> cos(pi/2)
 6.123234e-17

The e-17 means times 10−17.

Numbers with Exponents
For very big numbers or very small numbers:

2.4e3 means 2400
4.8e-2 means 0.048
8.2+3.4i is a complex number with real (8.2) and imaginary (3.4) parts

Just try typing the red command into the console box to see the output!

Modulo (Remainder)
Now suppose we wanted to know the remainder,
(what is left over when 234 is divided by 7),
in maths this is known as modulo.
Use %% (percent, percent)

> 234 %% 7
 3

Integer Quotients
How’s about the integer part of a division,
for last example, how many 7s are there in 234?
Use %/% (percent, divide, percent)

> 234 %/% 7
 33

Modulo is very useful for testing if odd or even:
odd numbers have modulo 2 value 1
even numbers have modulo 2 value 0

> 7 %% 2
 1
> 4 %% 2
 0

You use modulo to test if one number,
is an exact multiple of some other number.
For instance:
to find out whether 72 is a multiple of 8 or 7, ask:
> 72 %% 8 == 0
 TRUE
> 72 %% 7 == 0
 FALSE
72 is a multiple of 8, not 7.

Rounding
a) Rounding down
> floor(3.4)
 3

b) Rounding up
> ceiling(3.4)
 4

c) Rounding to the nearest integer
> round(3.4, digits=0)
 3
> round(3.5, digits=0)
 4

Shortcut: Use round(x,0)
> round(3.5, 0)
 4

So, hope you have learnt some of the basics!

to discuss the issues, i.e. problems, suggestions,