Vectorize in R
Letting the Vectorize function do the heavy-lifting when it comes to applying complicated control flows.
One of the cool things about R is that it is a vectorized language. This means that you can apply a vector (i.e., a series of values) to functions like sqrt
and log
without the need to write a for loop. While I was naive to how useful this was when learning R, in retrospect, I now very much appreciate this behavior.