Purrr

Learn to purrr

Purrr is the tidyverse's answer to apply functions for iteration. It's one of those packages that you might have heard of, but seemed too complicated to sit down and learn. Starting with map functions, and taking you on a journey that will harness the power of the list, this post will have you purrring in no time.

Rebecca Barter

Map functions: beyond apply Simplest usage: repeated looping with map The tilde-dot shorthand for functions Applying map functions in a slightly more interesting context Maps with multiple input objects List columns and Nested data frames Nesting the gapminder data Advanced exercise Additional purrr functionalities for lists Keep/Discard: select_if for lists Reduce Logical statements for lists Answer to advanced exercise “It was on the corner of the street that he noticed the first sign of something peculiar - a cat reading a map” - J.

Rebecca Barter

Data shaping: tidyr Gathering and spreading Combining and separating variables Replacing loops: purrr Loading data: readr Storing data: tibbles Dates, factors and strings: lubridate, forcats and stringr Handling dates and times: lubridate Handling factors: forcats Handling strings: stringr If you’re new to the tidyverse, I recommend that you first read part one of this two-part series on transitioning into the tidyverse. Part 1 focuses on what I feel are the most important aspects and packages of the tidyverse: tidy thinking, piping, dplyr and ggplot2.