Functional Programming with {purrr}

Functional Programming with {purrr}

Course Level: Foundation (6 hours)

This is a one-day course on the {tidyverse} package, {purrr}. {purrr} is a very powerful package that gives great flexibility to analysts, by enhancing R’s functional programming toolkit. We will demonstrate how to use functions such as map(), map2() and pmap(), to iteratively map functions over multi-element objects like vectors and lists. Emphasis will also be placed on how we can manipulate list outputs and how this can be applied to our data.

Download course details

Book: Functional Programming with {purrr}

Start Date:
Venue Details:

No Events Currently Scheduled

Sorry, there are no upcoming events for this course, but please get in touch if you would like to be kept informed when events are scheduled in the future.

Course Details


  • Introduction to {purrr} and Lists: Introduction to lists in R and using {purrr} to map a function across a list.
  • List-Columns and Nesting: Exploring nested data in list columns and using the mapping functions to manipulate them.
  • Parallel Mapping: Using {purrr} functions to map over multiple lists in parallel.
  • Manipulating {purrr} Output: Using {purrr} to efficiently extract elements from lists into vector and dataframe format, and change the hierarchy within nested lists.
  • Best Practices in {purrr}: Showcase of functions from {purrr} which aid in the debugging process.

Learning outcomes

Session 1:

By the end of session 1, participants will be able to…

  • understand lists in R and know how to use {purrr} to map functions.
  • know what nested loops are and use {magrittr} to extract elements from them.
  • be able to create list columns and know how to access the data in them.

Session 2:

By the end of session 2, participants will be able to…

  • iteratively loop two or more objects to a function of choice using functions such as map2(), pmap() and imap().
  • recognize the advantages of using {purrr}.
  • understand how to extract elements from nested lists to achieve a desired output object class.
  • be able to effectively debug their code using multiple {purrr} functions for the debugging process.
  • save precious debugging time using e.g. safely()

This course does not include:

  • The {stringr} package, also from the {tidyverse} which helps with splitting and combining strings, manipulating text data and working with regular expressions. Jumping Rivers run a Text Mining in R course which covers {stringr} in detail.

No in-depth coverage of the tidyverse data visualisation package {ggplot2}, see our course on this for more information.

Prior knowledge

This course assumes basic Tidyverse skills, so having attended Data Wrangling in the Tidyverse or equivalent is necessary. As this course involves iterative programming, basic familiarity with for loops may be helpful. You can learn about for loops on our Programming with R course.

Materials Preview

Attendee Feedback

  • “Dealing with lists is something I’ve always struggled with, but this course has given me so much more confidence in handling and manipulating them!”