Vectorised mathematical functions
\[\textbf{x} \quad of \quad length \quad n \quad (x_1, x_2, ..., x_n)\]
abs()
is vectorized:
## [1] 2 0 1 3 NA
Instead of defined to act on a single value (“scalar”) it is applied on each element:
\[ |\textbf{x}| = (|x_1|, |x_2|, ..., |x_n|) \]
It is the same for round
, floor
, etc but also log
and exp
(keep it mind changing the base of the log is an argument, default is base = exp(1)
)