Closed ijlyttle closed 2 years ago
This one is going to be a bear - it would not surprise me if it leaks into session 4 (by time). As a result, I plan to keep session 4 (by curriculum) light.
Our goal is to integrate tidyverse tidy-eval functions into your functions, so they work "seamlessly" for your users.
mutate(wt_kg = wt * 1000 / 2.2)
select(starts_with("w"))
mutate(wt_kg = wt * 1000 / 2.2)
, what we do in interactive programmingmutate("wt_kg" := .data[["wt"]] * 1000 / 2.2)
, useful for Shiny (esp. with string variables)...
to formals of uss_get_matches()
, pass ...
to dplyr::filter()
..data
and .env
pronouns [10 mins].data
and .env
pronouns to be unambiguous on the context of each variable..data
pronoun.env
to your package-toolkit: usethis::use_import_from("rlang", ".data")
uss_make_teams_matches()
, use .env$at_home
in mutate()
!!!
[5 mins]...
argument (similar to JavaScript destructuring)uss_make_teams_matches()
, splice rename_home()
, rename_visitor()
into rename()
"{}"
and :=
[5 mins]dplyr::mutate()
, dplyr::group_by()
, sometimes you need to create new column-names programmatically."{}"
as the left-side expression to create the name (uses glue internally):=
as the assignment operatoruss_make_teams_matches()
, dplyr::mutate("{name_of_at_home}" := .env$at_home)
across()
[10 mins]dplyr::across()
provides the bridge uss_make_teams_matches()
, convert arrange()
to use across()
uss_make_teams_matches()
in package vignette.uss_make_seasons_final()
[15 mins]This will be a free-form exercise, where:
seasons_intermediate()
and uss_make_seasons_cumulative()
uss_make_seasons_final()
which will be mostly a copy of uss_make_seasons_cumulative()
uss_make_seasons_final()
in package vignette{{}}
[15 mins]uss_plot_seasons_tiers()
, add aes_y
formal to function, use {{}}
to interpolate into ggplot2::aes()
.geom_point()
)wins - losses
)everything but the uss_results
object.
By the end of this session, you will be able to:
dplyr::group_by()