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
[1] 1 2 3 4 5
2^(1:5)

Output
[1]  2  4  8 16 32
x <- 1:5
2^x

Output
[1]  2  4  8 16 32


This is incredibly powerful; we will discuss this further in an upcoming lesson.