(Builds on: Lists, Function basics)
(Leads to: List columns, Scoped verbs)
Functions allow you to eliminate one type of duplication. The tools
of iteration, for loops and functional programming, allow you to eliminate
another. It’s good to understand how for loops work, but in this class
we’ll mostly focus on the map()
functions from purrr.
For loops [r4ds-21.2]. If you’ve ever written a for-loop in another programming language, you should find this fairly straightforward, and you can just skim this section to see how R is different.
The map functions [r4ds-21.5]