# Lesson 2: Values & Variables (CloudStat School)

January 8, 2012
By

(This article was first published on CloudStat, and kindly contributed to R-bloggers)

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!

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

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

Tags: , , , , ,