Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

3.1KB

---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
echo = FALSE,
warning = FALSE,
message = FALSE,
cache = TRUE
)
```

[gganimate]: https://github.com/thomasp85/gganimate#README

# Tidy Animated Verbs

Garrick Aden-Buie -- [&commat;grrrck](https://twitter.com/grrrck) -- [garrickadenbuie.com](https://www.garrickadenbuie.com)

[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/gadenbuie/tidy-animated-verbs/master?urlpath=rstudio)

- Mutate Joins: [`inner_join()`](#inner-join), [`left_join()`](#left-join),
[`right_join()`](#right-join), [`full_join()`](#full-join)

- Filtering Joins: [`semi_join()`](#semi-join), [`anti_join()`](#anti-join)

- Learn more about
- [Relational Data](#relational-data)
- [gganimate](#gganimate)

## Mutate Joins

```{r intial-dfs}
source("R/00_base.R")
df_names <- data_frame(
.x = c(1.5, 4.5), .y = 0.25,
value = c("x", "y"),
size = 12,
color = "black"
)

g <- plot_data(initial_dfs) +
geom_text(data = df_names, family = "Fira Mono", size = 24)

ggsave(g, file = here::here("images/original-dfs.png"))
```

<img src="images/original-dfs.png" width="480px" />

```{r echo=TRUE}
x
y
```

### Inner Join

```{r inner-join}
source("R/inner_join.R")
```

![](images/inner-join.gif)

```{r echo=TRUE}
inner_join(x, y, by = "id")
```

### Left Join

```{r left-join}
source("R/left_join.R")
```

![](images/left-join.gif)

```{r echo=TRUE}
left_join(x, y, by = "id")
```

### Left Join (Extra Rows in y)

```{r left-join-extra}
source("R/left_join_extra.R")
```

![](images/left-join-extra.gif)

```{r echo=TRUE}
y_extra # has multiple rows with the key from `x`
left_join(x, y_extra, by = "id")
```

### Right Join

```{r right-join}
source("R/right_join.R")
```

![](images/right-join.gif)

```{r echo=TRUE}
right_join(x, y, by = "id")
```

### Full Join

```{r full-join}
source("R/full_join.R")
```

![](images/full-join.gif)

```{r echo=TRUE}
full_join(x, y, by = "id")
```

## Filtering Joins

### Semi Join

```{r semi-join}
source("R/semi_join.R")
```

![](images/semi-join.gif)

```{r echo=TRUE}
semi_join(x, y, by = "id")
```

### Anti Join

```{r anti-join}
source("R/anti_join.R")
```

![](images/anti-join.gif)

```{r echo=TRUE}
anti_join(x, y, by = "id")
```

## Learn More

### Relational Data

The [Relational Data](http://r4ds.had.co.nz/relation-data.html) chapter of the
[R for Data Science](http://r4ds.had.co.nz/) book by Garrett Grolemund and Hadley Wickham
is an excellent resource for learning more about relational data.

The [dplyr two-table verbs vignette](https://dplyr.tidyverse.org/articles/two-table.html)
and Jenny Bryan's [Cheatsheet for dplyr join functions](http://stat545.com/bit001_dplyr-cheatsheet.html)
are also great resources.

### gganimate

The animations were made possible by the newly re-written [gganimate] package by
[Thomas Lin Pedersen](https://github.com/thomasp85)
(original by [Dave Robinson](https://github.com/dgrtwo)).
The [package readme][gganimate] provides an excellent (and quick) introduction to gganimte.