class: titleSlide, hide_logo # Data Wrangling ## Relational data <br> <center><img src="data:image/png;base64,#logo.png" width="200px"/></center> --- class: left, hide-count ### Joining different data tables is a very common task <center><img src="data:image/png;base64,#https://d33wubrfki0l68.cloudfront.net/245292d1ea724f6c3fd8a92063dcd7bfb9758d02/5751b/diagrams/relational-nycflights.png"/></center> --- class: left, hide-count ### Types of joins 1. Mutating joins: combine variables from two tables 2. Filtering joins: include or exclude rows but don't add new columns --- class: left, hide-count ### A simple example .pull-left[ **R4DS** <center><img src="data:image/png;base64,#https://d33wubrfki0l68.cloudfront.net/108c0749d084c03103f8e1e8276c20e06357b124/5f113/diagrams/join-setup.png"/></center> ] .pull-right[ **tidyexplain** <center><img src="data:image/png;base64,#https://www.garrickadenbuie.com/project/tidyexplain/images/static/png/original-dfs.png"/></center> ] --- class: left, hide-count ### Inner join <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/inner-join.gif"/></center> --- class: left, hide-count ### Left join <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/left-join.gif"/></center> --- class: left, hide-count ### Left join with extra rows in right (y) <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/left-join-extra.gif"/></center> --- class: left, hide-count ### Right join <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/right-join.gif"/></center> --- class: left, hide-count ### Full join <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/full-join.gif"/></center> --- class: left, hide-count ### Semi join <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/semi-join.gif"/></center> --- class: left, hide-count ### Anti join <center><img src="data:image/png;base64,#https://raw.githubusercontent.com/gadenbuie/tidyexplain/main/images/anti-join.gif"/></center> --- class: left, hide-count # Credits Deck by Eric Green ([@ericpgreen](https://twitter.com/ericpgreen)), licensed under Creative Commons Attribution [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) * {[`xaringan`](https://github.com/yihui/xaringan)} for slides with help from {[`xaringanExtra`](https://github.com/gadenbuie/xaringanExtra)} * [R for Data Science](https://r4ds.had.co.nz/index.html), by Wickham and Grolemund * {[`tidyexplain`](https://www.garrickadenbuie.com/project/tidyexplain/)} join animations