Photo by James Eades on Unsplash
The purrr
family of functions helps us replace for loops, making our code easier to read and more succint.
purrr
you canmap()
map2()
pmap()
invoke_map()
walk()
, walk2()
, and pwalk()
{fig-alt=“R4DS book cover”}
Ok, we love our earlier boxplot showing us body_mass_g by sex and colored by species…
…but let’s change up the colors to keep with our Antarctica theme!
I’m a big fan of the color palettes in the nord
📦
Let’s turn this plot…
…into this one!
Note: The color choices in this example are meant for demo purposes only. Be sure to consider the accessibility of your data viz, including color contrast between different elements.
You can choose colors using
the color hex codes
And assign them using the scale_fill_manual()
function
You can also use the palette name, like mountain_forms, though the colors assigned may not align with what you want
The prismatic
📦 helps us see the colors that correspond to each color hex code (mostly), with the color()
function
🎨 r-color-palettes repo from Emil Hvitfeldt
Like this Wes Anderson themed one! And many, many others 🤩