GitHub
LinkedIn
Twitter
YouTube
RSS

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 demonstatre 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.

Functional Programming with {purrr}

Price:
Venue Details:
Start Date:
Time:
Duration:

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
  • Manipulating {purrr} list output: Converting lists to concatenated vectors and joined data frames. In addition, list extraction.
  • 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
  • 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 {purrrr} over base R functions like lapply() and for loops
  • 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 safely()

Materials

Prior Knowledge

This course would assume familiarity with functional programming methods such as for loops. It is assumed that students have attended our Programming with R course (or have equivalent skills).

Attendee Feedback