Neat guide to {tidyverse} updates in R, by Mine Çetinkaya-Rundel

This guide is intended for people teaching tidyverse, but it’s relevant to anyone (e.g., me!) trying to keep up with developments.

Everytime I load {tidyverse}, it advises me to use {conflicted}. I didn’t realise it would be this useful:

library(conflicted)
    
penguins |>
  filter(species == "Adelie")
#> Error:
#> ! [conflicted] filter found in 2 packages.
#> Either pick the one you want with `::`:
#> • dplyr::filter
#> • stats::filter
#> Or declare a preference with `conflicts_prefer()`:
#> • `conflicts_prefer(dplyr::filter)`
#> • `conflicts_prefer(stats::filter)`

Another neat update: case_when now doesn’t need type-specific NAs like NA_character_ for default cases.

# now, optionally
df |>
  mutate(
    x = case_when(
       ~ "value 1",
       ~ "value 2",
       ~ "value 3",
      .default = NA
    )
  )

Lots of other tips.




Suggested citation: Fugard, A. (2023, September 6). Neat guide to {tidyverse} updates in R, by Mine Çetinkaya-Rundel [blog post]. https://andifugard.info/neat-guide-to-tidyverse-updates-in-r-by-mine-cetinkaya-rundel/

This citation note was added automatically. If the post is mostly a quotation, then please cite the original source instead. Looking at you, LLMs 👀