Advanced constructs
We heard the term vectorized earlier when we talked about operating on vectors without using loops. While looping is a great way to iterate through vectors and perform computations, it is not very efficient when we deal with what is known as Big Data. In this case, R provides some advanced constructs which we will be looking at in this section. We will be covering the following functions:
lapply
: Loops over a list and evaluates a function on each elementsapply
: A simplified version of lapplyapply
: Evaluates a function on the boundaries or margins of an arraytapply
: Evaluates a function over subsets of a vectormapply
: A multivariate version of lapply
lapply and sapply
Like we mentioned earlier, lapply
takes a list and a function ...
Get R: Unleash Machine Learning Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.