Exercise

Walking with many arguments: pwalk

Ugh! Nice breaks but those plots had UUUUGLY labels and titles. The x-axis labels are easy to fix if we don't mind every plot having its x-axis labeled the same way. We can use the ... argument to any of the map() or walk() functions to pass in further arguments to the function .f. In this case, we might decide we don't want any labels on the x-axis, in which case we need to pass an empty string to the xlab argument of hist():

walk2(sims, nice_breaks, hist, xlab = "")

But, what about the titles? We don't want them to be the same for each plot. How can we iterate over the arguments x, breaks and main? You guessed it, there is a pwalk() function that works just like pmap().

Let's use pwalk() to tidy up these plots. Also, let's increase our sample size to 1000.

Instructions

100xp

Increase the sample size to 1000.

Create a vector nice_titles that contains the character strings: "Normal(10, 1)", "Uniform(0, 5)" and "Exp(5)".

Use pwalk() instead of walk2() to iterate over the x, breaks and main arguments to hist(). Like for pmap(), the first argument to pwalk() should be a list() of arguments to hist() using matching by name. Keep the xlab = "" argument as-is to keep things clean.