class: inverse, left, bottom background-image: url(https://images.unsplash.com/photo-1542204165-65bf26472b9b?auto=format&fit=crop&q=80&w=1548&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D) background-size: cover # .Large[# My featurette] ## .small[featuring Hadley's waterfall chart from https://vita.had.co.nz/papers/ggplot2-wires.pdf] #### .tiny[Gina Reynolds | 2024-01-03 |Image credit: Denise Jans, Upsplash] ??? Title --- count: false .panel1-feature-auto[ ```r *library(tidyverse) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) *data.frame(event = c("Starting Cash", * "Sales", * "Refunds", * "Payouts", * "Court Losses", * "Court Wins", * "Contracts", * "End Cash"), * change = c(2000, 3400, -1100, * -100, -6600, 3800, * 1400, -2800)) ``` ] .panel2-feature-auto[ ``` ## event change ## 1 Starting Cash 2000 ## 2 Sales 3400 ## 3 Refunds -1100 ## 4 Payouts -100 ## 5 Court Losses -6600 ## 6 Court Wins 3800 ## 7 Contracts 1400 ## 8 End Cash -2800 ``` ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% * mutate(balance = cumsum(c(0, * change[-nrow(.)]))) ``` ] .panel2-feature-auto[ ``` ## event change balance ## 1 Starting Cash 2000 0 ## 2 Sales 3400 2000 ## 3 Refunds -1100 5400 ## 4 Payouts -100 4300 ## 5 Court Losses -6600 4200 ## 6 Court Wins 3800 -2400 ## 7 Contracts 1400 1400 ## 8 End Cash -2800 2800 ``` ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% mutate(balance = cumsum(c(0, change[-nrow(.)]))) %>% * mutate(time = row_number()) ``` ] .panel2-feature-auto[ ``` ## event change balance time ## 1 Starting Cash 2000 0 1 ## 2 Sales 3400 2000 2 ## 3 Refunds -1100 5400 3 ## 4 Payouts -100 4300 4 ## 5 Court Losses -6600 4200 5 ## 6 Court Wins 3800 -2400 6 ## 7 Contracts 1400 1400 7 ## 8 End Cash -2800 2800 8 ``` ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% mutate(balance = cumsum(c(0, change[-nrow(.)]))) %>% mutate(time = row_number()) %>% * mutate(flow = factor(sign(change))) ``` ] .panel2-feature-auto[ ``` ## event change balance time flow ## 1 Starting Cash 2000 0 1 1 ## 2 Sales 3400 2000 2 1 ## 3 Refunds -1100 5400 3 -1 ## 4 Payouts -100 4300 4 -1 ## 5 Court Losses -6600 4200 5 -1 ## 6 Court Wins 3800 -2400 6 1 ## 7 Contracts 1400 1400 7 1 ## 8 End Cash -2800 2800 8 -1 ``` ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% mutate(balance = cumsum(c(0, change[-nrow(.)]))) %>% mutate(time = row_number()) %>% mutate(flow = factor(sign(change))) -> *balance ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% mutate(balance = cumsum(c(0, change[-nrow(.)]))) %>% mutate(time = row_number()) %>% mutate(flow = factor(sign(change))) -> balance *ggplot(balance) ``` ] .panel2-feature-auto[ ![](waterfall_files/figure-html/feature_auto_07_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% mutate(balance = cumsum(c(0, change[-nrow(.)]))) %>% mutate(time = row_number()) %>% mutate(flow = factor(sign(change))) -> balance ggplot(balance) + * geom_rect( * aes(xmin = time - 0.45, * xmax = time + 0.45, * ymin = balance, * ymax = balance + change)) ``` ] .panel2-feature-auto[ ![](waterfall_files/figure-html/feature_auto_08_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) data.frame(event = c("Starting Cash", "Sales", "Refunds", "Payouts", "Court Losses", "Court Wins", "Contracts", "End Cash"), change = c(2000, 3400, -1100, -100, -6600, 3800, 1400, -2800)) %>% mutate(balance = cumsum(c(0, change[-nrow(.)]))) %>% mutate(time = row_number()) %>% mutate(flow = factor(sign(change))) -> balance ggplot(balance) + geom_rect( aes(xmin = time - 0.45, xmax = time + 0.45, ymin = balance, ymax = balance + change)) + * geom_text(aes(x = time, * y = pmin(balance, * balance + change) - 50, * label = balance)) ``` ] .panel2-feature-auto[ ![](waterfall_files/figure-html/feature_auto_09_output-1.png)<!-- --> ] <style> .panel1-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-feature-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- --- ### Contribute - https://github.com/EvaMaeRey/ggcirclepack --- ### Check out {packcircles} which does the computation in ggcirclepack - https://github.com/mbedward/packcircles --- ### Check out flipbookr, used to build this featurette - https://github.com/EvaMaeRey/flipbookr - discussion: https://github.com/EvaMaeRey/flipbookr/blob/master/docs/draft_jasa_submission.pdf --- ### Check out more featurettes - https://EvaMaeRey.github.io/featurette <style type="text/css"> .remark-code{line-height: 1.5; font-size: 100%} @media print { .has-continuation { display: block; } } </style>