Rendering a post using a {renv} profile with {dplyr} version 1.0.8.
To generate this demo, I:
distill::create_post("dplyr-108")
renv::activate(profile = "2022-03-14-dplyr-108")
renv::install(
"distill",
"rmarkdown",
"palmerpenguins",
"dplyr@1.0.8"
)
renv::snapshot()
To demonstrate package dependency control, I’ve installed {dplyr} version 1.0.8 for this post, which is the current version and includes the across()
function introduced in version 1.0.0.
I’ve written another post that uses an older version (0.8.5) of {dplyr} to prove that the dependencies don’t conflict.
We can prove the across()
function exists for the version of {dplyr} installed with the ‘2022-03-14-dplyr-108’ profile.
This means we can use across()
, rather than {dplyr}’s old approach of the *_if()
, *_at()
and *_all()
variants of verbs like mutate()
and summarise()
.
Here’s a very small example.
palmerpenguins::penguins %>%
select(where(is.factor)) %>%
mutate(across(c(species, island), tolower)) %>%
head()
# A tibble: 6 × 3
species island sex
<chr> <chr> <fct>
1 adelie torgersen male
2 adelie torgersen female
3 adelie torgersen female
4 adelie torgersen <NA>
5 adelie torgersen female
6 adelie torgersen male