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.