Tutorial introducing the purrr package for solving iteration problems
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
 Failed to load latest commit information. challenges Dec 13, 2016 code May 31, 2017 data May 31, 2017 .gitignore Dec 13, 2016 01-map.R May 31, 2017 02-typed-functions.R May 31, 2017 03-challenges.R May 31, 2017 04-map2.R Jun 2, 2017 05-purrr-list-columns.R May 31, 2017 06-other-features.R May 31, 2017 LICENSE.md May 31, 2017 README.md May 31, 2017 purrr_workshop.Rproj Dec 13, 2016 slides.pdf Jun 5, 2017 slides_with_transitions.pdf Jun 5, 2017 useR-abstract.md Mar 29, 2017

# A purrr tutorial

This repo hosts the materials for a purrr tutorial. The materials currently reflect the version planned for the Cascadia R Conf, Portland, OR Jun 2017.

## Upcoming in-person tutorials

Older versions of the materials, from prior in-person tutorials, are also available:

## 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")
``````