Data Challenge Lab Home

purrr basics [program]

(Builds on: Function basics)
(Leads to: List-columns, Other purrr functions, purrr map with multiple inputs)

You’ll often want to apply the same function to each element of a list or vector. Extracting each element and applying that function would be tedious, create a lot of duplicated code, and be nearly impossible for large lists and vectors. Instead, you can use the functions in the purrr package to iterate over lists and vectors and perform an action at each element.

In this unit, you’ll learn about the most basic purrr functions: the map functions. You’ll also learn about anonymous functions, which will allow you to create custom functions inside map functions.

Readings