Data Challenge Lab Home

purrr in mutate [program]

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

Until now, you’ve been using vector functions inside mutate() to create new columns. In Vector functions, you learned how to convert some scalar functions into vector functions. Sometimes, however, you’ll want to use a scalar function to create a new column, and you won’t be able to convert that scalar function into a vector function.

In this reading, you’ll learn how to create new columns with a scalar function by using a map function to apply that scalar function to each element of an existing column.

Readings