class: title-slide, center, bottom # Take A Sad Plot & Make It Better ## A Case Study with R and ggplot2 ### Alison Hill · RStudio #### R-Ladies Melbourne Meetup · 2019-09-26 --- name: hello class: inverse, right, bottom <img style="border-radius: 50%;" src="https://github.com/apreshill.png" width="150px"/> # Find me at... [
@apreshill](http://twitter.com/apreshill) [
@apreshill](http://github.com/apreshill) [
alison.rbind.io](https://alison.rbind.io) [
alison@rstudio.com](mailto:alison@rstudio.com) --- background-image: url(images/aim-here.png) background-size: contain --- background-image: url(images/feature-keepgoing-hi-rectangle.jpg) background-size: cover --- class: inverse, middle, center # Autism prevalence <img src="images/number-with-autistic-spectrum-disorder.png" width="50%" style="display: block; margin: auto;" /> .footnote[ https://ourworldindata.org/neurodevelopmental-disorders ] --- class: inverse, middle, center # Autism prevalence <img src="images/nature-autism-rising.png" width="50%" style="display: block; margin: auto;" /> .footnote[[Nature](https://www.nature.com/articles/479022a)] --- class: inverse, middle, center # Autism prevalence <img src="images/autism-speaks-2018-prevalence.jpg" width="50%" style="display: block; margin: auto;" /> .footnote[[Autism Speaks](https://www.autismspeaks.org/science-news/cdc-increases-estimate-autisms-prevalence-15-percent-1-59-children)] --- class: inverse, top, center # California: 1931 to 2014 <img src="https://media.springernature.com/lw785/springer-static/image/art%3A10.1007%2Fs10803-018-3670-2/MediaObjects/10803_2018_3670_Fig7_HTML.gif" width="50%" style="display: block; margin: auto;" /> .footnote[ https://doi.org/10.1007/s10803-018-3670-2 ] --- class: center, middle, inverse # `v1.ppt` -- # 🎶 .fancy[Hey, Jude, don't make it bad...] 🎶 --- background-image: url("./images/version1.png") background-size: contain --- # Blameless postmortem .pull-left[ ![](images/version1.png) ] -- .pull-right[ - 😃 Pink < green- always under-estimating. - 😏 More dots in the pink blob - more people are getting services, but... - 😬 The "true" prevalence (total number of dots) looks different. It is actually the same at both time points! - 😳 I actually like the dots! And I return to this later. ] --- class: center, inverse, middle <img src="images/lightbulb-color.png" width="10%" style="display: block; margin: auto;" /> -- # What is the message? -- Is there an autism epidemic? Based on the data available, we don't know! --- class: center, inverse, middle <img src="images/lightbulb-color.png" width="10%" style="display: block; margin: auto;" /> -- # What is the medium? -- A book chapter, but also presentations like this one! --- background-image: url(images/aim-here-v1.png) background-size: contain --- class: center, middle, inverse # `v2.doc` -- # 🎶 .fancy[Take a sad (plot) and make it better...] 🎶 --- class: center background-image: url("./images/version2.png") background-size: contain --- class: center, middle, inverse ![](images/beatles-face-palm.gif) --- # Full-of-blame postmortem .pull-left[ ![](images/version2.png) ] .pull-right[ - 😡 Franken-plot - 🍬-coated pies ] --- background-image: url(images/aim-here-v2.png) background-size: contain --- class: center, middle, inverse # `v3 <- ggplot()` -- # 🎶 .fancy[Then you'll begin to make it better...] 🎶 --- class: center, middle, inverse ![](images/beatles-help.gif) --- class: center, middle # Asking for help .pull-left[ ![](images/help-me-viz-logo.jpg) ] .pull-right[ Help Me Viz [https://policyviz.com/helpmeviz/](https://policyviz.com/helpmeviz/) *"A place to facilitate discussion, debate, and collaboration from the data visualization community"* ] --- class: center, middle, inverse ![](images/help-me-newcat.png) --- class: center background-image: url("./images/help-me-plea.png") background-size: auto --- class: center background-image: url("./images/help-me-response.png") background-size: auto --- class: center, inverse, middle <img src="images/lightbulb-color.png" width="10%" style="display: block; margin: auto;" /> -- # I can use ggplot2! --- ```r set.seed(1000) asdpop_base <- tibble::tibble( time1 = sample(1:100, 100, replace = F), time2 = time1) %>% tidyr::gather(x, y, time1:time2, factor_key = TRUE) asdpop_base ``` ``` # A tibble: 200 x 2 x y <fct> <int> 1 time1 33 2 time1 76 3 time1 12 4 time1 68 5 time1 50 6 time1 7 7 time1 70 8 time1 55 9 time1 20 10 time1 24 # … with 190 more rows ``` --- ```r asdpop <- asdpop_base %>% mutate(services = as.factor(case_when( x == "time1" & y <= 30 ~ 1, x == "time1" & y > 30 ~ 0, x == "time2" & y <= 60 ~ 1, TRUE ~ 0 ))) asdpop ``` ``` # A tibble: 200 x 3 x y services <fct> <int> <fct> 1 time1 33 0 2 time1 76 0 3 time1 12 1 4 time1 68 0 5 time1 50 0 6 time1 7 1 7 time1 70 0 8 time1 55 0 9 time1 20 1 10 time1 24 1 # … with 190 more rows ``` --- background-image: url(images/Painter.png) background-size: contain background-position: right center .footnote[Art by [Desirée De Leon](http://desiree.rbind.io/), <br>[CC-BY-NC-ND](https://tinystats.github.io/teacups-giraffes-and-statistics/)] --- class: center <img src="figs/bar1-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar2-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar3-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar4-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar5-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar6-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar7-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/bar8-1.png" width="60%" style="display: block; margin: auto;" /> --- background-image: url(images/aim-here-v3.png) background-size: contain --- class: center, bottom, inverse # `rep("better", 40)` -- # 🎶 better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better, better...🎶 --- class: center, middle, inverse # Why I ❤️ ggplot2 ![](images/beatles-rotation.gif) --- class: center <img src="figs/dot1-1.png" width="60%" style="display: block; margin: auto;" /> --- background-image: url(images/ggplot2_masterpiece.png) background-size: contain background-position: right center .footnote[Artwork by [@allison_horst](https://twitter.com/allison_horst)] --- <img src="figs/dot1-2-1.png" width="60%" style="display: block; margin: auto;" /> --- <img src="figs/dot2-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/dot3-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/dot4-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/dot5-1.png" width="60%" style="display: block; margin: auto;" /> --- exclude: TRUE <img src="figs/unnamed-chunk-8-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/dot6-1.png" width="60%" style="display: block; margin: auto;" /> --- class: center <img src="figs/dot7-1.png" width="60%" style="display: block; margin: auto;" /> --- <img src="figs/dot8-1.png" width="60%" style="display: block; margin: auto;" /> --- <img src="figs/waffle-1.png" width="60%" style="display: block; margin: auto;" /> --- background-image: url(images/gganimate_fireworks.png) background-size: contain background-position: right center .footnote[Artwork by [@allison_horst](https://twitter.com/allison_horst)] --- <img src="figs/unnamed-chunk-9-1.gif" width="60%" style="display: block; margin: auto;" /> --- <img src="figs/unnamed-chunk-10-1.gif" width="60%" style="display: block; margin: auto;" /> --- background-image: url(images/rachel-martin-PnAc2UaeqII-unsplash.jpg) background-position: left background-size: contain class: center, middle, inverse .pull-right[ ## Thanks! Slide theme developed by [Desirée De Leon](http://desiree.rbind.io/). Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan). The chakra comes from [remark.js](https://remarkjs.com), [**knitr**](http://yihui.name/knitr), and [R Markdown](https://rmarkdown.rstudio.com). This work is licensed under a Creative Commons Attribution- ShareAlike 4.0 International License. To view a copy of this license, visit: https://creativecommons.org/licenses/by-sa/4.0/ ]