Training Course Details

Functional Programming with purrr

Functional Programming with purrr

Course Level: Foundation

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.

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.

View our full training course calendar »

Course Details

  • Course Outline
  • Learning Outcomes
  • Materials
  • Prior Knowledge

Course Outline

  • What are lists?: A brief introduction explaining how list objects are used in the R ecosystem
  • Introduction to {purrr}: Mapping functions across vectors and lists using map() - an alternative to for loops
  • List columns and nesting: Nesting data in list columns and using the mapping funtions to manipulate them
  • Parallel mapping: Using map2(), pmap() and imap() to map over objects in parallel
  • Manipulating {purrr} list output: Converting lists to concatenated vectors and joined data frames. In addition, list extraction.
  • Good practices: Using safely() to aid in the debugging process

Learning Outcomes

By the end of the course, participants will be able to…

  • use {purrr} mapping functions to pass each element of an object to a function
  • recognise the advantages of using {purrr}
  • manipulate list output to achieve a desired output object class
  • nest data in list columns to store data across different observations
  • iteratively loop two or more objects to a function of choice using functions such as map2(), pmap() and imap()
  • save precious deubugging time using e.g. safely()


  • Example course material for 'Functional Programming with purrr
  • Example course material for 'Functional Programming with purrr
  • Example course material for 'Functional Programming with purrr
  • Example course material for 'Functional Programming with purrr

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.

Attendee Feedback