zest_join: zest join

Description Usage Arguments Value Examples

View source: R/zest_join.R

Description

a zest join is similar to a dplyr::nest_join() but the rows of y that are included in the list column are controlled by a predicate.

Usage

1
zest_join(x, y, ...)

Arguments

x

a tibble

y

another tibble

...

named predicate formulas

The rhs of the formulas is used y dplyr::filter() on y for each row of x.

  • Literal column names refer to columns of y. Alternatively you can use .data$.

  • To use the current value for a column of x you can use unquoting, e.g. !!cyl

Value

a tibble that contains all columns and rows of x, plus an additional list column per formula:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
tbl <- tibble::tibble(cyl = c(4, 6, 8), mpg = c(30, 25, 20))

# zest join of tbl and mtcars
# - the created column is called `data`
# - each element of the data column is the result of filter(mtcars, cyl == !!cyl & mpg < !!mpg)
#    - `cyl` and `mpg` refer to columns of `y`
#    - `!!cyl` and `!!mpg` refer to the current
tbl %>%
  zest_join(mtcars, data = ~cyl == !!cyl & mpg < !!mpg)

# similar to
tbl %>%
  rap(data = ~filter(mtcars, cyl == !!cyl & mpg < !!mpg))

# multiple zest
tbl %>%
  zest_join(mtcars,
    one = ~cyl == !!cyl & mpg < !!mpg,
    two = ~cyl <  !!cyl & mpg > !!mpg
  )

romainfrancois/rap documentation built on Dec. 14, 2018, 3:02 p.m.