September 2019 has been a great month for us. We officially launched our website and started building our brand with @rfindingyourway.
Let’s recap some of the things we’ve learned this month and seen in the #rstats community.
- Bring all
library("foobar")calls to the top with{packup} - Use prefix notation for infix operators
- Interactively build
{ggplot2}charts with{esquisse} spread()’s dead in{tidyr}v1.0- Mara Averick brings good game to explaining
hoist()with GIF
Tidy up loading pkgs with {packup}
One of our daily tweets reminded folks to load packages at the top of scripts. We were delighted to discover @MilesMcBain’s {packup} package which contains an RStudio add-in to automate moving library("pkg") to the top of RMarkdown documents!
Always load packages at the top of your #rstats scripts.
— finding youR way (@rfindingyourway) September 9, 2019
It's extremely important that your scripts don't have a "special order" in which code is run, a user should be able to open your script and get it to work with these two steps:
- ⌘+A / Ctrl+A
- ⌘+Enter / Ctrl+Enter
Prefix notation with backtick operators
We discovered that the dplyr::add_tally() function includes a really nice example of prefixed infix operators — so nice that we tweeted about it and wrote a blogpost about it.
ggplot2 GUI with {esquisse}
On our training courses we’re often asked about a GUI for building {ggplot2} charts. Before September our answer was always “we don’t know about one”.
Now we recommend the excellent {esquisse} package, see dreamrs.github.io/esquisse/ for more details.
Using the GUI comes with a disclaimer. Hadley Wickham has a great slide deck on why data science can’t be done in a GUI, which is why we’d always teach the fundamentals of {ggplot2} so you can iterate away from the boilerplate dataviz that {esquisse} allows you to create.
spread()’s dead, baby, spread()’s dead
gather() and spread() have been retired as the workhorses of {tidyr} with the release of v1.0 in favour of the more expressive and versatile pivot_longer() and pivot_wider(), respectively.
We ended up writing a short dedicated blogpost on this topic, which includes a summary of our Twitter poll on the subject with 196 responses.
hoist() animations from @dataandme
The release of {tidyr} v1.0 brings many new features to the tidyverse for working with nested tibbles — which is affectionately called rectangling. These rectangling functions are fairly complex, and often the simplest way to explain them is with a GIF.
We particularly enjoyed the hoist() animated GIF from Mara Averick, and hope to see more function demos in the near future!
🤖
— Mara Averick (@dataandme) September 30, 2019tidyr::hoist()robot-arm edition…#rstats pic.twitter.com/vrG8simf9z