Underrated Tidyverse Functions

Learn about our assignment to teach the tidyverse to each other.

Ted Laderas

The Assignment

I’m teaching an R Programming course next term. Jessica Minnier and I are developing the Ready for R Materials into a longer and more involved course.

I think one of the most important things is to teach people how to self-learn. As learning to program is a lifelong learning activity, it’s critically important to give them these meta-learning skills. So that’s the motivation behind the Tidyverse function of the Week assignment.

I asked on Twitter:

Hi Everyone. I'm teaching an #rstats course next quarter.

One assignment is to have each student write about a #tidyverse function. What it's for and an example.

What are some less known #tidyverse functions that do a job you find useful?

— Ted Laderas, PhD 🏳️‍🌈 (@tladeras) November 30, 2020

Some of my favorite suggestions

Here are some of the highlights from the thread.

I loved all of these. Danielle Quinn wins the MVP award for naming so many useful functions:

tidyr::fill() / replace_na()
stringr::str_detect() / str_which()
lubridate::ymd_hms() and related functions
ggplot2::labs() - so simple, yet under appreciated!

— Danielle Quinn (she/her) (@daniellequinn88) December 1, 2020

fill() was highly suggested:

tidyr::fill() - extremely useful when creating a usable dataset out of a spreadsheet originally built for data entry, in which redundant informations are only reported once at the beginning of the group they refer to, rather than in every row as needed for the analysis.

— Luca Foppoli (@foppoli_luca) December 1, 2020

Many people suggested the window functions, including lead() and lag() and the cumulative functions:

Check out the dplyr window functions, cummin, cummax, cumany and cumall. They don't seen useful at first but they can solve really tricky aggregation problems. https://t.co/aDpXqSB2Vx

— Robert Kubinec (@rmkubinec) December 1, 2020