Suggest/joins (#1469)
* - better to make code compatible with the figure - better to remove the last row: 1 Max NA - make sure at leaset one employee born before Jan 10, and make output reproducible * Use join_by() --------- Co-authored-by: Mine Çetinkaya-Rundel <cetinkaya.mine@gmail.com>
This commit is contained in:
parent
6b90ffda93
commit
d5b151c360
|
@ -673,7 +673,7 @@ In equi joins the `x` keys and `y` are always equal, so we only need to show one
|
|||
We can request that dplyr keep both keys with `keep = TRUE`, leading to the code below and the re-drawn `inner_join()` in @fig-inner-both.
|
||||
|
||||
```{r}
|
||||
x |> left_join(y, by = "key", keep = TRUE)
|
||||
x |> inner_join(y, join_by(key == key), keep = TRUE)
|
||||
```
|
||||
|
||||
```{r}
|
||||
|
@ -771,7 +771,7 @@ One small useful technique is to use them to restrict the cross join so that ins
|
|||
```{r}
|
||||
df <- tibble(id = 1:4, name = c("John", "Simon", "Tracy", "Max"))
|
||||
|
||||
df |> left_join(df, join_by(id < id))
|
||||
df |> inner_join(df, join_by(id < id))
|
||||
```
|
||||
|
||||
### Rolling joins
|
||||
|
@ -811,6 +811,7 @@ parties <- tibble(
|
|||
Now imagine that you have a table of employee birthdays:
|
||||
|
||||
```{r}
|
||||
set.seed(123)
|
||||
employees <- tibble(
|
||||
name = sample(babynames::babynames$name, 100),
|
||||
birthday = ymd("2022-01-01") + (sample(365, 100, replace = TRUE) - 1)
|
||||
|
|
Loading…
Reference in New Issue