purrr
A functional programming toolkit for R
purrr provides a complete and consistent toolkit for functional programming in R, focused primarily on the map() family of functions that allow you to apply operations across vectors and lists. It enables you to replace for loops with more concise and readable code.
The package offers several advantages over base R: it works naturally with the pipe operator, guarantees type-stable outputs (each function returns a predictable type or throws an error), and supports flexible function specifications using named functions, anonymous functions, lambda syntax, or shortcuts for extracting elements by name or position. It also includes built-in progress tracking for long-running operations and parallel computation support.
Contributors#
Resources featuring purrr#
Advent of Code for R users | Emil Hvitfeldt | Data Science Lab
The Data Science Lab is a live weekly call. Register at pos.it/dslab! Discord invites go out each week on lives calls. We’d love to have you!
The Lab is an open, messy space for learning and asking questions. Think of it like pair coding with a friend or two. Learn something new, and share what you know to help others grow.
On this call, Libby Heeren is joined by Posit engineer Emil Hvitfeldt as he walks through Day 1 of Advent of Code 2026 using R. This is a super friendly, collaborative, and cheery intro to AoC! Don’t forget, you can do Advent of Code at any ole time of year
Hosting crew from Posit: Libby Heeren, Isabella Velasquez, Daniel Chen, Emil Hvitfeldt
Emil’s socials and urls: website: https://emilhvitfeldt.com/ GitHub: https://github.com/emilhvitfeldt Bluesky: https://bsky.app/profile/emilhvitfeldt.bsky.social LinkedIn: https://www.linkedin.com/in/emilhvitfeldt/
Resources from the hosts and chat:
Advent of Code: https://adventofcode.com/ Install Positron: https://positron.posit.co/ Eric Wastl, Advent of Code: Behind the Scenes: https://www.youtube.com/watch?v=_oNOTknRTSU AoC Subreddit: https://www.reddit.com/r/adventofcode/ Kieran Healy shared a reddit post with an Advent of Code answer done in Minecraft: https://www.reddit.com/r/adventofcode/comments/1pbeyxx/2025_day_01_part_2_advent_of_code_in_minecraft/ Emil’s Solutions: https://github.com/EmilHvitfeldt/rstats-adventofcode Emil’s helper package: https://github.com/EmilHvitfeldt/aocfuns purrr::accumulate() function: https://purrr.tidyverse.org/reference/accumulate.html
And, for anyone hangin’ in there at the end, Emil updated us on Discord that he figured out why his cumsum() didn’t work: he forgot to start the dial at 50! Once you fix that, it works to solve part 1 :)
► Subscribe to Our Channel Here: https://bit.ly/2TzgcOu
Follow Us Here: Website: https://www.posit.co The Lab: https://pos.it/dslab Hangout: https://pos.it/dsh LinkedIn: https://www.linkedin.com/company/posit-software Bluesky: https://bsky.app/profile/posit.co
Thanks for learning with us!
Timestamps 00:00 Introduction 01:01 Tour of the Advent of Code website 02:30 Dashboard overview and puzzle schedule 03:23 How to view and access previous years’ events 03:37 Structure of puzzles: Two parts and stars 04:40 Understanding the global leaderboard 05:08 “Does that ASCII art build itself? 06:16 Setting up private leaderboards for friend 07:54 Starting Day 1: Story prompt and mechanics 09:30 Understanding unique puzzle inputs 10:51 Submission feedback and delay penalties 11:44 Safe dial logic: Left, Right, and circularity 12:50 Starting position and Part 1 success criteria 14:09 Setting up the project in Positron 16:26 Strategy for speed: Reading from the bottom up 18:49 Problem-solving strategies: Pen, paper, and visualization 19:22 Walking through the logic with a sample case 20:52 Coding Part 1: Data parsing and vectorization 23:17 Positron keyboard shortcuts for duplicating lines 24:40 Debugging the logic and handling negative numbers 26:03 Explaining the Modulo operator (%%) 28:15 Managing large inputs of over 4,000 instructions 29:21 Submitting Part 1 and transitioning to Part 2 32:03 Part 2 challenge: Counting zero “clicks” 34:02 Brainstorming Part 2 code modifications 36:19 Checking important warnings for edge cases 37:00 Coding Part 2: Nested loops and incrementing counters 38:23 Hint: Modulo vs. integer division 40:40 Success with the Part 2 test case 42:30 Alternative method: Vectorized cumulative sums 45:29 “What’s the difference between % and %%?” (percent vs modulo) 46:50 Mathematical optimization to avoid inner loops

Purrrfectly parallel, purrrfectly distributed (Charlie Gao, Posit) | posit::conf(2025)
Purrrfectly parallel, purrrfectly distributed
Speaker(s): Charlie Gao
Abstract:
purrr is a powerful functional programming toolkit that has long been a cornerstone of the tidyverse. In 2025, it receives a modernization that means you can use it to harness the power of all computing cores on your machine, dramatically speeding up map operations.
More excitingly, it opens up the doors to distributed computing. Through the mirai framework used by purrr, this is made embarrassingly simple. For those in small businesses, or even large ones – every case where there is a spare server in your network, you can now put to good use in simple, straightforward steps.
Let us show you how distributed computing is no longer the preserve of those with access to high performance compute clusters.
Materials - https://shikokuchuo-posit2025.share.connect.posit.cloud/ posit::conf(2025) Subscribe to posit::conf updates: https://posit.co/about/subscription-management/

What does deprecated mean? Package lifecycle and the process of deprecation.
An important part of the process of package lifecycle and package development is not just adding new functions. It’s equally important to remove functions.
Hadley Wickham shares about the package lifecycle process and what ‘deprecation’ means for functions.
See the full video about the purrr 1.0 release: https://youtu.be/EGAs7zuRutY
More about the package lifecycle stages: https://lifecycle.r-lib.org/articles/stages.html
Maintaining the house that tidyverse built: https://youtu.be/izFssYRsLZs

What does superseded mean? Package development lifecycle process and the meaning of superseded.
An important part of the process of package lifecycle and package development is not just adding new functions. It’s is equally important to remove functions.
Hadley Wickham shares about the package lifecycle process and what ‘supersede’ means for functions.
See the full video about the purrr 1.0 release: https://youtu.be/EGAs7zuRutY
More about the package lifecycle stages: https://lifecycle.r-lib.org/articles/stages.html
Maintaining the house that tidyverse built: https://youtu.be/izFssYRsLZs

posit::conf(2023) Workshop: From R User to R Programmer
Register now: http://pos.it/conf Instructors: Emma Rand and Ian Lyttle Workshop Duration: 1-Day Workshop
This course is for you if you: • have experience equivalent to an introductory data science course using tidyverse • feel comfortable with the Whole game chapter of R for Data Science
This is a one-day, hands-on workshop for those who have embraced the tidyverse and want to improve their R programming skills and, especially, reduce the amount of duplication in their code. The two main ways to reduce duplication are creating functions and using iteration. We will use a tidyverse approach to cover function design and iteration with {purrr}.
• Master the art of writing functions that do one thing well, adhere to existing conventions and can be fluently combined together to solve more complex problems. • Learn how to perform the same action on many objects using code which is succinct and easy to read
Hadley Wickham | {purrr} 1.0: A complete and consistent set of tools for functions and vectors
{purrr} has reached the 1.0 milestone, with new features like progress bars, improvements to the map family, and tools for list flattening and simplification.
0:00 Introduction 0:11 What is purrr? 00:32 What is functional programming? 03:08 Announcing purrr 1.0 03:58 Progress bars 05:18 Better error messages 07:18 New map function: map_vec() 09:58 New list_* functions 12:04 Flattening and simplification 17:40 Breaking Changes 22:34 How the tidyverse handles deprecation 24:41 An overview of functional programming 26:22 Closing, resources to help with deprecation, how to submit issues
See more in the {purrr} 1.0.0 release blog post! https://www.tidyverse.org/blog/2023/03/tidyverse-2-0-0/

Edgar Ruiz | Programación con R | RStudio (2019)
Hay ocasiones que, cuando trabajamos en un análisis en R, necesitamos dividir nuestros datos en grupos, y después tenemos que correr la misma operación sobre cada grupo. Por ejemplo, puede ser que los datos que tenemos contienen varios países, y necesitamos crear un modelo por cada país. Otro caso sería el de correr múltiples operaciones sobre los mismos datos. Estos casos requieren que sepamos cómo usar iteraciones con R. Este webinar se concentrará en cómo utilizar el paquete llamado purrr para ayudarnos a resolver este tipo de problema.
Descargar materiales: https://rstudio.com/resources/webinars/programacio-n-con-r/
About Edgar: Edgar Ruiz es un Ingeniero de Soluciones en RStudio. Es el administrador de los sitios oficiales de sparklyr y de R para bases de datos. También es autor de los paquetes de R: dbplot, tidypredict y modeldb, y co-autor de el paquete dbplyr

Hadley Wickham | testthat 3.0.0 | RStudio (2020)
In this webinar, I’ll introduce some of the major changes coming in testthat 3.0.0. The biggest new idea in testthat 3.0.0 is the idea of an edition. You must deliberately choose to use the 3rd edition, which allows us to make breaking changes without breaking old packages. testthat 3e deprecates a number of older functions that we no longer believe are a good idea, and tweaks the behaviour of expect_equal() and expect_identical() to give considerably more informative output (using the new waldo package).
testthat 3e also introduces the idea of snapshot tests which record expected value in external files, rather than in code. This makes them particularly well suited to testing user output and complex objects. I’ll show off the main advantages of snapshot testing, and why it’s better than our previous approaches of verify_output() and expect_known_output().
Finally, I’ll go over a bunch of smaller quality-of-life improvements, including tweaks to test reporting and improvements to expect_error(), expect_warning() and expect_message().
Webinar materials: https://rstudio.com/resources/webinars/testthat-3/
About Hadley: Hadley Wickham is the Chief Scientist at RStudio, a member of the R Foundation, and Adjunct Professor at Stanford University and the University of Auckland. He builds tools (both computational and cognitive) to make data science easier, faster, and more fun. You may be familiar with his packages for data science (the tidyverse: including ggplot2, dplyr, tidyr, purrr, and readr) and principled software development (roxygen2, testthat, devtools, pkgdown). Much of the material for the course is drawn from two of his existing books, Advanced R and R Packages, but the course also includes a lot of new material that will eventually become a book called “Tidy tools”


