purrr is a walk() in the park

1. purrr is a walk() in the park

walk() helps make purrr cleaner, it helps us create outputs that are more human-readable, which is vital when sharing results with everyone on your team, and doing it in a compact way.

2. Why walk()?

Regular list output is filled with bracketed elements and isn't very easy to read. This is why purrr has the walk() function, which helps make a list output more human-readable. It outputs the same information as normal list output, but it's much more compact and easier to search through. walk() works much like map(), in that it takes both a dot x and a dot f argument. To use walk() to print out our short_list, we use short_list the first or dot x argument, and print as the second or dot f argument.

3. Plots, the normal way

When working in RMarkdown documents, we often need to print out many figures. If those figures are stored in a list, then we can use walk() to print them out without any of the double square bracket indexing. On the left of the slide, we see the output produced by printing the plots using the name of the list along with the graphs on the right.

4. walk() with plots

When we use walk() to print plots, we just need to supply the name of the list as the first argument and print as the second argument. This time, however, there is no output to the console, just the plots on the right.

5. Let's purrr-actice!

Now let's try some examples.