Variables are everywhere, let’s understand a bit more about their structures in the R programming language.

A variable is a quantity, quality or property that you can measure.
But what is it in practice?
Everytime we create an object, we are also creating a kind of variable
In fact, it’s good to remember that:
\(\color{blue}{\text{"Everything that exists in R is an object."}}\) ~John M. Chambers
So basically we will be dealing with variables all the time!
To understand the 4 main types of variables, you should create the following objects in your workspace:
TRUE"text"1Each object is interpreted in a different way by the language, let’s
use the function class() to understand how each variable
behaves:
Type in the following after creating the objects:
class(logical)
class(character)
class(numeric)
class(factor)
You should have the following answers:
[1] "logical"
[1] "character"
[1] "numeric"
[1] "factor"
Each object belongs to a different class, therefore should be treated as such.
TRUE or FALSE"text",
"this is a text", "th1s 1s 4ls0 a t3xt".Remembering that in truth programming languages are just fancy calculators:
+ add- subtract* multiply/ divide^ exponentiationThis is a factor:
as.factor(c("I", "am", "a", "factor"))
This is also a factor:
as.factor(c(1, 2, 3, 4))
The word ORDER is the most important one here to define factors
These are the main 4 structures that will appear in your analyses!
Follow me on twitter: @gimbgomes