Lesson 2: Values & Variables (CloudStat School)

[This article was first published on CloudStat, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is the second lesson of CloudStat School, Lesson 2: Values & Variables.

At the end of the lesson 2, you should know:

1. Inserting values into valuables
2. Calling valuables
3. Simple operation within variables.

2.1 Assign/Insert Values into Variables
There are 2 symbols can be used:
i) less than minus, <-
abc <- 123
ii) equal, =
xyz = 321 
By typing these commands, you are assigning the
value of 123 into variable abc. Same as 321 into xyz.

2.2 Calling Values from Variables.
To see the values have been assigned into variables,
we need to call them.
To call values from variables, simply type variables’ names.
In this case (from 2.1):
abc
xyz
Click “Run” button to see the result.

2.3 Assign & Call Variables
> abc <- 123
> xyz = 321
> abc
[1] 123
> xyz
[1] 321
You have assigned the values of 123 and 321
into abc and xyz repectively.

2.4 Simple Mathematic Operation with Variables
The common math operators are
plus +
minus
multiple *
division /
Remain the last commands, type and run:
abc + xyz
xyz – abc

You will see:

> abc + xyz
[1] 444
> xyz – abc
[1] 198

abc + xyz means 123 + 321, so you got 444 
xyz – abc means 321 – 123, you got 198

That’s just for warm-up!
But hope you had learnt about:

1. Inserting values into valuables
2. Calling valuables
3. Simple operation within variables.

To leave a comment for the author, please follow the link and comment on their blog: CloudStat.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)