Using R as a Calculator
Vectorization
One final thing to be aware of is that R is vectorized, meaning that variables and functions can have vectors as values. In contrast to physics and mathematics, a vector in R describes a set of values in a certain order of the same data type. For example:
1:5
Output |
---|
|
2^(1:5)
Output |
---|
|
x <- 1:5
2^x
Output |
---|
|
This is incredibly powerful; we will discuss this further in an upcoming lesson.