Tutorial: Solving iteration problems with purrr
Event Information
Description
The biggest R conference, useR!, is coming up! 4 days packed with tutorials and talks - but don't despair if you can't make it:
Charlotte Wickham is visiting us! She will be giving a condensed version of her useR! tutorial on the purrr package for solving iteration problems.
Charlotte is a part-time Assistant Professor of Statistics at Oregon State University, specialist in R training and course developer for Data Camp. Her DataCamp courses are Writing functions in R - with her brother, Hadley Wickham - and Working with Geospatial Data in R.
Please see below for more details on the (standard) purrr tutorial including pre-requisites (hint: beginner/intermediate level and please install some packages beforehand as there is no public wifi):
Outline
Code with a lot of duplication is harder to understand, troubleshoot and maintain. The goal of this tutorial is help you remove duplication in your code by using functions that write `for` loops for you.
You'll learn to use the functions in the `purrr` package to perform iterative tasks: tasks that look like "for each _____ do _____".
By the end of the tutorial you'll be writing code that is more readable and easier to update and you'll be ready to solve new iteration problems faster and with fewer mistakes.
Learning Objectives
By the end of the tutorial, you'll be able to:
• Move from solving a problem on a single element, to iterating that solution over many elements with `map()`.
• Identify when to use the typed variants of `map()`: `map_lgl()`, `map_int()`, `walk()` etc.
• Iterate over two arguments with `map2()`.
• Leverage `purrr` to get list data into tibbles.
• Use `purrr` to work with list columns in tibbles.
Pre-requisites
Don't worry if you have never written a `for` loop, used `lapply()`, written your own function or heard of a `tibble`, this tutorial is designed to be accessible to beginners.
That said, you should be familiar with exploring and subsetting the basic data structures in R including lists and data frames.
This is a hands-on tutorial, you'll need your laptop with R installed, as well as a few packages:
```
install.packages("tidyverse")
# install.packages("devtools")
devtools::install_github("jennybc/repurrrsive")
```
----------------------------------------------------------------------------------------------------------------------------------------------
Code of Conduct: We expect all attendees to abide and be governed by our community CoC.