All Projects β†’ gadenbuie β†’ Tidyexplain

gadenbuie / Tidyexplain

Licence: cc0-1.0
πŸ€Ήβ€β™€ Animations of tidyverse verbs using R, the tidyverse, and gganimate

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Tidyexplain

Sergeant
πŸ’‚ Tools to Transform and Query Data with 'Apache' 'Drill'
Stars: ✭ 120 (-78.49%)
Mutual labels:  sql, dplyr, rstats
Moderndive book
Statistical Inference via Data Science: A ModernDive into R and the Tidyverse
Stars: ✭ 527 (-5.56%)
Mutual labels:  dplyr, ggplot2, rstats
parcours-r
Valise pΓ©dagogique pour la formation Γ  R
Stars: ✭ 25 (-95.52%)
Mutual labels:  ggplot2, dplyr
learning R
List of resources for learning R
Stars: ✭ 32 (-94.27%)
Mutual labels:  ggplot2, dplyr
Ggalt
🌎 Extra Coordinate Systems, Geoms, Statistical Transformations & Scales for 'ggplot2'
Stars: ✭ 561 (+0.54%)
Mutual labels:  ggplot2, rstats
casewhen
Create reusable dplyr::case_when() functions
Stars: ✭ 64 (-88.53%)
Mutual labels:  dplyr, rstats
DataViz-Teaching
πŸ“ˆ Visualizations for DataViz Teaching
Stars: ✭ 29 (-94.8%)
Mutual labels:  ggplot2, rstats
Ggpointdensity
πŸ“ˆ πŸ“Š Introduces geom_pointdensity(): A Cross Between a Scatter Plot and a 2D Density Plot.
Stars: ✭ 286 (-48.75%)
Mutual labels:  ggplot2, rstats
CSSS508
CSSS508: Introduction to R for Social Scientists
Stars: ✭ 28 (-94.98%)
Mutual labels:  ggplot2, dplyr
Ggpage
Creates Page Layout Visualizations in R πŸ“„πŸ“„πŸ“„
Stars: ✭ 306 (-45.16%)
Mutual labels:  ggplot2, rstats
Ggextra
πŸ“Š Add marginal histograms to ggplot2, and more ggplot2 enhancements
Stars: ✭ 299 (-46.42%)
Mutual labels:  ggplot2, rstats
Ggsignif
Easily add significance brackets to your ggplots
Stars: ✭ 322 (-42.29%)
Mutual labels:  ggplot2, rstats
scclusteval
Single Cell Cluster Evaluation
Stars: ✭ 57 (-89.78%)
Mutual labels:  ggplot2, rstats
ggchicklet
πŸ€« Create Chicklet (Rounded Segmented Column) Charts
Stars: ✭ 130 (-76.7%)
Mutual labels:  ggplot2, rstats
cusumcharter
Easier CUSUM control charts. Returns simple CUSUM statistics, CUSUMs with control limit calculations, and function to generate faceted CUSUM Control Charts
Stars: ✭ 17 (-96.95%)
Mutual labels:  ggplot2, rstats
layer
Create stacked tilted maps
Stars: ✭ 97 (-82.62%)
Mutual labels:  ggplot2, rstats
Hexsticker
✨ Hexagon sticker in R
Stars: ✭ 464 (-16.85%)
Mutual labels:  ggplot2, rstats
Tidyquery
Query R data frames with SQL
Stars: ✭ 138 (-75.27%)
Mutual labels:  sql, dplyr
Ggpomological
πŸ‘ Pomological plot theme for ggplot2
Stars: ✭ 293 (-47.49%)
Mutual labels:  ggplot2, rstats
Tidytuesday
πŸ“Š My contributions to the #TidyTuesday challenge
Stars: ✭ 410 (-26.52%)
Mutual labels:  ggplot2, rstats

Tidy Animated Verbs

Garrick Aden-Buie – @grrrck – garrickadenbuie.com. Set operations contributed by Tyler Grant Smith.

Binder CC0 MIT

Background

Usage

Please feel free to use these images for teaching or learning about action verbs from the tidyverse. You can directly download the original animations or static images in svg or png formats, or you can use the scripts to recreate the images locally.

Currently, the animations cover the dplyr two-table verbs and I’d like to expand the animations to include more verbs from the tidyverse. Suggestions are welcome!

Relational Data

The Relational Data chapter of the R for Data Science book by Garrett Grolemund and Hadley Wickham is an excellent resource for learning more about relational data.

The dplyr two-table verbs vignette and Jenny Bryan’s Cheatsheet for dplyr join functions are also great resources.

gganimate

The animations were made possible by the newly re-written gganimate package by Thomas Lin Pedersen (original by Dave Robinson). The package readme provides an excellent (and quick) introduction to gganimate.

Dynamic Animations

Thanks to an initial push by David Zimmermann, we have begun work toward a packaged set of functions to generate dynamic explanatory animations from users' actual data. Please visit the pkg branch of the tidyexplain repository for more information (or to contribute!).

Mutating Joins

A mutating join allows you to combine variables from two tables. It first matches observations by their keys, then copies across variables from one table to the other.
R for Data Science: Mutating joins

x
#> # A tibble: 3 x 2
#>      id x    
#>   <int> <chr>
#> 1     1 x1   
#> 2     2 x2   
#> 3     3 x3
y
#> # A tibble: 3 x 2
#>      id y    
#>   <int> <chr>
#> 1     1 y1   
#> 2     2 y2   
#> 3     4 y4

Inner Join

All rows from x where there are matching values in y, and all columns from x and y.

inner_join(x, y, by = "id")
#> # A tibble: 2 x 3
#>      id x     y    
#>   <int> <chr> <chr>
#> 1     1 x1    y1   
#> 2     2 x2    y2

Left Join

All rows from x, and all columns from x and y. Rows in x with no match in y will have NA values in the new columns.

left_join(x, y, by = "id")
#> # A tibble: 3 x 3
#>      id x     y    
#>   <int> <chr> <chr>
#> 1     1 x1    y1   
#> 2     2 x2    y2   
#> 3     3 x3    <NA>

Left Join (Extra Rows in y)

… If there are multiple matches between x and y, all combinations of the matches are returned.

y_extra # has multiple rows with the key from `x`
#> # A tibble: 4 x 2
#>      id y    
#>   <dbl> <chr>
#> 1     1 y1   
#> 2     2 y2   
#> 3     4 y4   
#> 4     2 y5
left_join(x, y_extra, by = "id")
#> # A tibble: 4 x 3
#>      id x     y    
#>   <dbl> <chr> <chr>
#> 1     1 x1    y1   
#> 2     2 x2    y2   
#> 3     2 x2    y5   
#> 4     3 x3    <NA>

Right Join

All rows from y, and all columns from x and y. Rows in y with no match in x will have NA values in the new columns.

right_join(x, y, by = "id")
#> # A tibble: 3 x 3
#>      id x     y    
#>   <int> <chr> <chr>
#> 1     1 x1    y1   
#> 2     2 x2    y2   
#> 3     4 <NA>  y4

Full Join

All rows and all columns from both x and y. Where there are not matching values, returns NA for the one missing.

full_join(x, y, by = "id")
#> # A tibble: 4 x 3
#>      id x     y    
#>   <int> <chr> <chr>
#> 1     1 x1    y1   
#> 2     2 x2    y2   
#> 3     3 x3    <NA> 
#> 4     4 <NA>  y4

Filtering Joins

Filtering joins match observations in the same way as mutating joins, but affect the observations, not the variables. … Semi-joins are useful for matching filtered summary tables back to the original rows. … Anti-joins are useful for diagnosing join mismatches.
R for Data Science: Filtering Joins

Semi Join

All rows from x where there are matching values in y, keeping just columns from x.

semi_join(x, y, by = "id")
#> # A tibble: 2 x 2
#>      id x    
#>   <int> <chr>
#> 1     1 x1   
#> 2     2 x2

Anti Join

All rows from x where there are not matching values in y, keeping just columns from x.

anti_join(x, y, by = "id")
#> # A tibble: 1 x 2
#>      id x    
#>   <int> <chr>
#> 1     3 x3

Set Operations

Set operations are occasionally useful when you want to break a single complex filter into simpler pieces. All these operations work with a complete row, comparing the values of every variable. These expect the x and y inputs to have the same variables, and treat the observations like sets.
R for Data Science: Set operations

x
#> # A tibble: 3 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 1     a    
#> 2 1     b    
#> 3 2     a
y 
#> # A tibble: 2 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 1     a    
#> 2 2     b

Union

All unique rows from x and y.

union(x, y)
#> # A tibble: 4 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 2     b    
#> 2 2     a    
#> 3 1     b    
#> 4 1     a

union(y, x)
#> # A tibble: 4 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 2     a    
#> 2 1     b    
#> 3 2     b    
#> 4 1     a

Union All

All rows from x and y, keeping duplicates.

union_all(x, y)
#> # A tibble: 5 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 1     a    
#> 2 1     b    
#> 3 2     a    
#> 4 1     a    
#> 5 2     b

Intersection

Common rows in both x and y, keeping just unique rows.

intersect(x, y)
#> # A tibble: 1 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 1     a

Set Difference

All rows from x which are not also rows in y, keeping just unique rows.

setdiff(x, y)
#> # A tibble: 2 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 1     b    
#> 2 2     a

setdiff(y, x)
#> # A tibble: 1 x 2
#>   x     y    
#>   <chr> <chr>
#> 1 2     b

Tidy Data

Tidy data follows the following three rules:

  1. Each variable has its own column.
  2. Each observation has its own row.
  3. Each value has its own cell.

Many of the tools in the tidyverse expect data to be formatted as a tidy dataset and the tidyr package provides functions to help you organize your data into tidy data.

wide
#> # A tibble: 2 x 4
#>      id x     y     z    
#>   <int> <chr> <chr> <chr>
#> 1     1 a     c     e    
#> 2     2 b     d     f
long
#> # A tibble: 6 x 3
#>      id key   val  
#>   <int> <chr> <chr>
#> 1     1 x     a    
#> 2     2 x     b    
#> 3     1 y     c    
#> 4     2 y     d    
#> 5     1 z     e    
#> 6     2 z     f

Spread and Gather

spread(data, key, value)

Spread a key-value pair across multiple columns. Use it when an a column contains observations from multiple variables.

gather(data, key = "key", value = "value", ...)

Gather takes multiple columns and collapses into key-value pairs, duplicating all other columns as needed. You use gather() when you notice that your column names are not names of variables, but values of a variable.

gather(wide, key, val, x:z)
#> # A tibble: 6 x 3
#>      id key   val  
#>   <int> <chr> <chr>
#> 1     1 x     a    
#> 2     2 x     b    
#> 3     1 y     c    
#> 4     2 y     d    
#> 5     1 z     e    
#> 6     2 z     f
spread(long, key, val)
#> # A tibble: 2 x 4
#>      id x     y     z    
#>   <int> <chr> <chr> <chr>
#> 1     1 a     c     e    
#> 2     2 b     d     f
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].