Return a list of expressions all piped together as a single expression
expr_pipe.Rd
Useful when making complex compound statements that require dynamic substitution via tidy eval for dynamically created variables derived from the context.
Arguments
- exprs
expressions
Seeexprs
Examples
(.data <- tibble::tibble(val = runif(10)))
#> # A tibble: 10 × 1
#> val
#> <dbl>
#> 1 0.0808
#> 2 0.834
#> 3 0.601
#> 4 0.157
#> 5 0.00740
#> 6 0.466
#> 7 0.498
#> 8 0.290
#> 9 0.733
#> 10 0.773
(exp <- expr_pipe(
rlang::exprs(
.data,
dplyr::mutate(val = val + 5, category = sample(1:3, length(val), replace = TRUE)),
dplyr::group_by(category),
dplyr::summarise(s = sum(val))
)
))
#> dplyr::summarise(dplyr::group_by(dplyr::mutate(.data, val = val +
#> 5, category = sample(1:3, length(val), replace = TRUE)),
#> category), s = sum(val))
rlang::eval_bare(exp)
#> # A tibble: 3 × 2
#> category s
#> <int> <dbl>
#> 1 1 22.1
#> 2 2 16.1
#> 3 3 16.2