class: center, middle, inverse, title-slide # the ggplot flipbook ## made with xaringan ### Gina Reynolds ### 2019/01/31 --- <!-- #Table of Contents --> <!-- - [Visual Table of Contents](#visualtoc) --> <!-- - [Introduction](#introduction) --> <!-- - [What's the slow ggplot workflow?](#whatsslow) --> <!-- - [Getting started with R and RStudio](#gettingstarted) --> <!-- - [Acknowledgements](#acknowledgements) --> <!-- - [The tidyverse](#thetidyverse) --> # Introduction The ggplot2 package in the programming language R implements the "layered grammar of graphics" --- a proposal of Leland Wilkinson and the product of the dissertation and ongoing work of Hadley Wickham. This data visualization system idea is at once powerful, novel, and intuitive. Wickham and collaborators have built a system where data visualization is dividable into parameters: data to visualize, aesthetics that represent variables, geometric objects, a coordinate system, specific scales, and statistical transformation. In this book, I use a "slow ggplotting" method as well as a "flipbook" format to facilitate the introduction of this plotting method. "Slow ggplotting" makes modifications to plots as incrementally as possible so that it is clear to users what code triggers each new layer or modification. The aim is less to be concise, and more to be explicit about how new statements modify the plot; repetition should facilitating more interactions with ggplotting to help newcomers internalize the functions. The flipbook layout is designed to show what code is triggering each change in the plot output. Readers of the book should easily be able to follow along with how plots are built up. While intuitive, using ggplotting effectively and efficiently nevertheless requires practice. My hope is that these examples will be a helpful reference point for those that endeavor to pick up data visualization with ggplot2. --- name: whatsslow # What's the slow ggplot workflow? "Slow ggplot" just means working more incrementally than is typical. Elements of the approach are as follows: - pulling out aes() from the ggplot() function: - using fewer functions; example - using labs() to add a title instead of ggtitle() - using functions multiple times; example aes(x = var1) + aes(y = var2) rather than aes(x = var1, y = var2) - using base R functions and tidyverse functions. For other packages, the :: style to call them - write out arguments (no shortcuts) aes(x = gdppercap) not aes(gdppercap) - order ggplot commands so that reactivity is obvious; scale adjustments to aesthetics might also be near the aesthetic declaration. --- Here, I contrast the usual plotting method to slow ggplotting: Usual approach: ```r ggplot(my_data, aes(var1, y = var2, col = var3)) + geom_point() + ggtitle("My Title") + labs(x = "the x label", y = "the y label", col = "legend title") ``` Using slow ggplotting: ```r ggplot(data = my_data) + aes(x = var1) + labs(x = "the x label") + aes(y = var2) + labs(y = "the y label") + geom_point() + aes(col = var3) + labs(col = "legend title") + labs(title = "My title") ``` --- name: gettingstarted # Getting started with R and RStudio - [Install Windows](https://www.youtube.com/watch?v=aCRMhAWmtpw) - [Install Mac](https://www.youtube.com/watch?v=GLLZhc_5enQ) --- name: acknowledgements # Acknowledgements I'm grateful to the ggplot team for their tireless work on developing and maintaining this fantastic resource. Additionally most of the visualizations here were produced for the Tableau-users-associated initiative #MakeoverMonday. I'm grateful to that community for feedback and encouragement and for welcoming work from outside of Tableau. Additional visualizations have been made with data curated by #TidyTuesday, a similar initiative from RStudio. Many thanks are due to Emi Tanaka (@statsgen) and Garrick Aden-Buie (@grrrck) helped by writing the "reveal" function to made the flipbook style possible. Also to Yihui Xie and others that work on the Xaringan package for creating slides from markdown and R code; I'm using Emi Tanaka's themes kunoichi and ninjutsu. While I'm hopeful that this book serves as a reference, I think the best introductions and learning happens in person. My formal introduction to ggplot2 was at The Zurich Summer School for Women in Political Methodology in 2017 at the University of Zürich. I'm very grateful to the organizers and presenters of that workshop; Denise Traber gave an excellent presention on ggplot2. I'm grateful too to my students who motivate me to think about how to teach what I've been so lucky to learn. And thanks to David, who is supportive of plotting and of me. --- name:visualtoc #Visual Table of Contents <a href="#christmastreesales"><img src="figures/christmas.png"width="150" height="150" title=figures/christmas.png alt=figures/christmas.png></a><a href="#baseball"><img src="figures/baseball.png"width="150" height="150" title=figures/baseball.png alt=figures/baseball.png></a><a href="#parentalleave"><img src="figures/parent_leave.png"width="150" height="150" title=figures/parent_leave.png alt=figures/parent_leave.png></a><a href="#traits"><img src="figures/traits.png"width="150" height="150" title=figures/traits.png alt=figures/traits.png></a><a href="#salaries"><img src="figures/white_house.png"width="150" height="150" title=figures/white_house.png alt=figures/white_house.png></a><a href="#wintergamemedals"><img src="figures/winter_games.png"width="150" height="150" title=figures/winter_games.png alt=figures/winter_games.png></a> <a href="#brexit"><img src="figures/brexit_1.png"width="150" height="150" title=figures/brexit_1.png alt=figures/brexit_1.png></a><a href="#britishburgers"><img src="figures/map_curry.png"width="150" height="150" title=figures/map_curry.png alt=figures/map_curry.png></a><a href="#britishfood"><img src="figures/away_from_ben.png"width="150" height="150" title=figures/away_from_ben.png alt=figures/away_from_ben.png></a><a href="#lifeexpect"><img src="figures/life_expect.png"width="150" height="150" title=figures/life_expect.png alt=figures/life_expect.png></a><a href="#myersbriggs"><img src="figures/myers_briggs.png"width="150" height="150" title=figures/myers_briggs.png alt=figures/myers_briggs.png></a><a href="#womensrepresentation"><img src="figures/women.png"width="150" height="150" title=figures/women.png alt=figures/women.png></a> <a href="#wine"><img src="figures/wine.png"width="150" height="150" title=figures/wine.png alt=figures/wine.png></a><a href="#ice"><img src="figures/ice.png"width="150" height="150" title=figures/ice.png alt=figures/ice.png></a><a href="#collegemajors01"><img src="figures/recent_grads_01.png"width="150" height="150" title=figures/recent_grads_01.png alt=figures/recent_grads_01.png></a><a href="#collegemajors02"><img src="figures/recent_grads_02.png"width="150" height="150" title=figures/recent_grads_02.png alt=figures/recent_grads_02.png></a><a href="#flippingseats"><img src="figures/flipping_seats.png"width="150" height="150" title=figures/flipping_seats.png alt=figures/flipping_seats.png></a><a href="#ratings"><img src="figures/company_ranks.png"width="150" height="150" title=figures/company_ranks.png alt=figures/company_ranks.png></a> [More on next page](#visualtoc2) --- name: visualtoc2 #Visual Table of Contents <a href="#incarcerationbysex"><img src="figures/incarceration_01.png"width="150" height="150" title=figures/incarceration_01.png alt=figures/incarceration_01.png></a><a href="#incarcerationbygender"><img src="figures/incarceration_02.png"width="150" height="150" title=figures/incarceration_02.png alt=figures/incarceration_02.png></a><a href="#milkindustry"><img src="figures/milk.png"width="150" height="150" title=figures/milk.png alt=figures/milk.png></a><a href="#windturbinelocations01"><img src="figures/wind_01.png"width="150" height="150" title=figures/wind_01.png alt=figures/wind_01.png></a><a href="#windturbinelocations02"><img src="figures/wind_02.png"width="150" height="150" title=figures/wind_02.png alt=figures/wind_02.png></a><a href="#movies"><img src="figures/movies.png"width="150" height="150" title=figures/movies.png alt=figures/movies.png></a> --- --- name: christmastreesales # Christmas Trees Here is a simple plot of Christmas Tree Sales in the U.S. The plot shows that artificial tree sales are on the rise, contrasting with declines in real trees. The title plays on the German Christmas Carol "O Tannenbaum", "Oh Christmas Tree" in English. "Wie echt sind deine Blätter?" means "how real are your leaves"; the original text from the carol is "Wie treu sind deine Blätter!" which means "How true your leaves are!" I also plot the cumulative number of trees purchased of each type, artificial and real, from 2004 to 2014, comparing that to the 2016 U.S. population. Almost one real tree per person was bought over the course of 10 years! ```r library(tidyverse) ``` A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> Year </th> <th style="text-align:right;"> Number of trees sold </th> <th style="text-align:left;"> Type of tree </th> <th style="text-align:right;"> Number of trees sold (millions) </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 2009 </td> <td style="text-align:right;"> 11700000 </td> <td style="text-align:left;"> Fake tree </td> <td style="text-align:right;"> 11.7 </td> </tr> <tr> <td style="text-align:right;"> 2005 </td> <td style="text-align:right;"> 9300000 </td> <td style="text-align:left;"> Fake tree </td> <td style="text-align:right;"> 9.3 </td> </tr> <tr> <td style="text-align:right;"> 2015 </td> <td style="text-align:right;"> 12500000 </td> <td style="text-align:left;"> Fake tree </td> <td style="text-align:right;"> 12.5 </td> </tr> <tr> <td style="text-align:right;"> 2008 </td> <td style="text-align:right;"> 11700000 </td> <td style="text-align:left;"> Fake tree </td> <td style="text-align:right;"> 11.7 </td> </tr> <tr> <td style="text-align:right;"> 2016 </td> <td style="text-align:right;"> 27400000 </td> <td style="text-align:left;"> Real tree </td> <td style="text-align:right;"> 27.4 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = dta) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + * aes(x = Year) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + * aes(y = `Number of trees sold (millions)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + * geom_point() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + * aes(col = fct_rev(`Type of tree`)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + * geom_smooth(method = "lm", se = F) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + geom_smooth(method = "lm", se = F) + * scale_color_manual(values = * c("darkgreen", "green")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + geom_smooth(method = "lm", se = F) + scale_color_manual(values = c("darkgreen", "green")) + * ylim(c(0, 35)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + geom_smooth(method = "lm", se = F) + scale_color_manual(values = c("darkgreen", "green")) + ylim(c(0, 35)) + * labs(col = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + geom_smooth(method = "lm", se = F) + scale_color_manual(values = c("darkgreen", "green")) + ylim(c(0, 35)) + labs(col = "") + * labs(title = "Wie echt sind deine Blätter?") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + geom_smooth(method = "lm", se = F) + scale_color_manual(values = c("darkgreen", "green")) + ylim(c(0, 35)) + labs(col = "") + labs(title = "Wie echt sind deine Blätter?") + * labs(subtitle = "Real and fake Christmas trees sold in the US | Data Source: Statista | @EvaMaeRey ") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = `Number of trees sold (millions)`) + geom_point() + aes(col = fct_rev(`Type of tree`)) + geom_smooth(method = "lm", se = F) + scale_color_manual(values = c("darkgreen", "green")) + ylim(c(0, 35)) + labs(col = "") + labs(title = "Wie echt sind deine Blätter?") + labs(subtitle = "Real and fake Christmas trees sold in the US | Data Source: Statista | @EvaMaeRey ") + * theme_bw() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_christmas_13-1.png" width="80%" /> ]] --- name: baseball # Baseball, WAR, and Ethnicity This data visualization uses the WAR measure in baseball, a calculation based on the contributions of players. The visualizations show that new ethnicities and races started to be included in Major League baseball, the minority players that joined tended to contribute more than the expected value for players overall. For example, from 1947, when Jackie Robinson joined Major League baseball, and onward, the percent of African American players was outpaced by the percent calculated contributions (WAR) of African American players. A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> Year </th> <th style="text-align:left;"> Ethnicity </th> <th style="text-align:left;"> type </th> <th style="text-align:right;"> Percent </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 1948 </td> <td style="text-align:left;"> Asian </td> <td style="text-align:left;"> % of WAR </td> <td style="text-align:right;"> 0.0 </td> </tr> <tr> <td style="text-align:right;"> 1995 </td> <td style="text-align:left;"> Latino </td> <td style="text-align:left;"> % of Players </td> <td style="text-align:right;"> 19.2 </td> </tr> <tr> <td style="text-align:right;"> 1960 </td> <td style="text-align:left;"> Asian </td> <td style="text-align:left;"> % of WAR </td> <td style="text-align:right;"> 0.0 </td> </tr> <tr> <td style="text-align:right;"> 1952 </td> <td style="text-align:left;"> African American </td> <td style="text-align:left;"> % of Players </td> <td style="text-align:right;"> 2.9 </td> </tr> <tr> <td style="text-align:right;"> 1979 </td> <td style="text-align:left;"> African American </td> <td style="text-align:left;"> % of WAR </td> <td style="text-align:right;"> 24.2 </td> </tr> <tr> <td style="text-align:right;"> 2006 </td> <td style="text-align:left;"> Latino </td> <td style="text-align:left;"> % of Players </td> <td style="text-align:right;"> 27.9 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> Asian </td> <td style="text-align:left;"> % of Players </td> <td style="text-align:right;"> 0.0 </td> </tr> <tr> <td style="text-align:right;"> 1984 </td> <td style="text-align:left;"> Asian </td> <td style="text-align:left;"> % of WAR </td> <td style="text-align:right;"> 0.0 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(df_gather) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + * aes(x = Year, y = Percent) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + * facet_wrap(~ Ethnicity) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + * geom_area(alpha = .5, * position = "dodge") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + geom_area(alpha = .5, position = "dodge") + * aes(fill = type) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + geom_area(alpha = .5, position = "dodge") + aes(fill = type) + * labs(fill = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + geom_area(alpha = .5, position = "dodge") + aes(fill = type) + labs(fill = "") + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + geom_area(alpha = .5, position = "dodge") + aes(fill = type) + labs(fill = "") + labs(x = "") + * labs(title = "American Baseball Demographics 1947-2016") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + geom_area(alpha = .5, position = "dodge") + aes(fill = type) + labs(fill = "") + labs(x = "") + labs(title = "American Baseball Demographics 1947-2016") + * labs(subtitle = "Percentage of players and WAR percentage (WAR is a calculation of value contributed)\nData: SABR.org | Vis: @EvaMaeRey for #MakeoverMonday") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_gather) + aes(x = Year, y = Percent) + facet_wrap(~ Ethnicity) + geom_area(alpha = .5, position = "dodge") + aes(fill = type) + labs(fill = "") + labs(x = "") + labs(title = "American Baseball Demographics 1947-2016") + labs(subtitle = "Percentage of players and WAR percentage (WAR is a calculation of value contributed)\nData: SABR.org | Vis: @EvaMaeRey for #MakeoverMonday") + * theme_light() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_baseball_11-1.png" width="80%" /> ]] --- --- # Hic sunt dracones! This book is not complete. The plots that follow aren't as carefully edited as what precedes. But feel free to have a look around. This "here be dragons" slide should move later and later on as weeks go by. Also I hope to add new work as time goes on. --- name:parentalleave # Maternal Leave The OECD provides a comparative report on how much paid leave women are entitled to after childbirth. But leave takes different forms. In some places, the allowed leave is longer, but sometimes that means that the pay out compared to the regular salary is lower. To emphasize the different forms that law around paid leave take, I plotted the total payout available to mothers as areas of rectangles, where one side is the length of leave allowed, and the other side is the proportion of salary paid to the new mom. A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Country </th> <th style="text-align:right;"> Paid maternity leave avg payment rate (%) </th> <th style="text-align:right;"> Paid maternity leave full rate equivalent in weeks </th> <th style="text-align:right;"> Paid maternity leave in weeks </th> <th style="text-align:right;"> Paid parental leave avg payment rate (%) </th> <th style="text-align:right;"> Paid parental leave full rate equivalent in weeks </th> <th style="text-align:right;"> Paid parental leave in weeks </th> <th style="text-align:right;"> Total paid leave avg payment rate (%) </th> <th style="text-align:right;"> Total paid leave full rate equivalent in weeks </th> <th style="text-align:right;"> Total paid leave in weeks </th> <th style="text-align:left;"> rank_name </th> <th style="text-align:right;"> paid_leave_months </th> <th style="text-align:right;"> total_paid_yearly_salaries </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Belgium </td> <td style="text-align:right;"> 64.1 </td> <td style="text-align:right;"> 9.6 </td> <td style="text-align:right;"> 15 </td> <td style="text-align:right;"> 20.2 </td> <td style="text-align:right;"> 3.5 </td> <td style="text-align:right;"> 17.3 </td> <td style="text-align:right;"> 40.6 </td> <td style="text-align:right;"> 13.1 </td> <td style="text-align:right;"> 32.3 </td> <td style="text-align:left;"> #27: Belgium </td> <td style="text-align:right;"> 7.433425 </td> <td style="text-align:right;"> 0.2519231 </td> </tr> <tr> <td style="text-align:left;"> Canada </td> <td style="text-align:right;"> 48.4 </td> <td style="text-align:right;"> 8.2 </td> <td style="text-align:right;"> 17 </td> <td style="text-align:right;"> 54.9 </td> <td style="text-align:right;"> 19.2 </td> <td style="text-align:right;"> 35.0 </td> <td style="text-align:right;"> 52.8 </td> <td style="text-align:right;"> 27.4 </td> <td style="text-align:right;"> 52.0 </td> <td style="text-align:left;"> #15: Canada </td> <td style="text-align:right;"> 11.967123 </td> <td style="text-align:right;"> 0.5269231 </td> </tr> <tr> <td style="text-align:left;"> United States </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:right;"> 0.0 </td> <td style="text-align:left;"> #35: United States </td> <td style="text-align:right;"> 0.000000 </td> <td style="text-align:right;"> 0.0000000 </td> </tr> <tr> <td style="text-align:left;"> Czech Republic </td> <td style="text-align:right;"> 62.6 </td> <td style="text-align:right;"> 17.5 </td> <td style="text-align:right;"> 28 </td> <td style="text-align:right;"> 43.4 </td> <td style="text-align:right;"> 35.6 </td> <td style="text-align:right;"> 82.0 </td> <td style="text-align:right;"> 48.3 </td> <td style="text-align:right;"> 53.1 </td> <td style="text-align:right;"> 110.0 </td> <td style="text-align:left;"> #5: Czech Republic </td> <td style="text-align:right;"> 25.315068 </td> <td style="text-align:right;"> 1.0211538 </td> </tr> <tr> <td style="text-align:left;"> Iceland </td> <td style="text-align:right;"> 59.7 </td> <td style="text-align:right;"> 7.8 </td> <td style="text-align:right;"> 13 </td> <td style="text-align:right;"> 59.7 </td> <td style="text-align:right;"> 7.8 </td> <td style="text-align:right;"> 13.0 </td> <td style="text-align:right;"> 59.7 </td> <td style="text-align:right;"> 15.5 </td> <td style="text-align:right;"> 26.0 </td> <td style="text-align:left;"> #25: Iceland </td> <td style="text-align:right;"> 5.983562 </td> <td style="text-align:right;"> 0.2980769 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(df) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + * aes(x = paid_leave_months) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + * aes(y = `Total paid leave avg payment rate (%)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + * aes(xmin = 0) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + * aes(xmax = paid_leave_months) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + * aes(ymin = 0) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + * aes(ymax = `Total paid leave avg payment rate (%)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + * facet_wrap(fct_inorder(rank_name) ~ .) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + * geom_rect(fill = "blue", alpha = .2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + * aes(yend = 0) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + * aes(xend = 0) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + * geom_segment( * aes(yend = `Total paid leave avg payment rate (%)`), * lty = "dashed") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + * geom_segment(aes(xend = paid_leave_months), * lty = "dashed") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + * scale_y_continuous(limits = c(0, 100), * expand = c(0, 0), * breaks = c(0, 50, 100)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_19-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + scale_y_continuous(limits = c(0, 100), expand = c(0, 0), breaks = c(0, 50, 100)) + * scale_x_continuous(limits = c(0, 44), * expand = c(0, 0)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_21-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + scale_y_continuous(limits = c(0, 100), expand = c(0, 0), breaks = c(0, 50, 100)) + scale_x_continuous(limits = c(0, 44), expand = c(0, 0)) + * labs(x = "Length of paid leave entitlement (months)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_22-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + scale_y_continuous(limits = c(0, 100), expand = c(0, 0), breaks = c(0, 50, 100)) + scale_x_continuous(limits = c(0, 44), expand = c(0, 0)) + labs(x = "Length of paid leave entitlement (months)") + * labs(y = "Percent of income paid (average over entitlement period)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_23-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + scale_y_continuous(limits = c(0, 100), expand = c(0, 0), breaks = c(0, 50, 100)) + scale_x_continuous(limits = c(0, 44), expand = c(0, 0)) + labs(x = "Length of paid leave entitlement (months)") + labs(y = "Percent of income paid (average over entitlement period)") + * labs(title = "Total paid leave available to mothers in the OECD") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_24-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + scale_y_continuous(limits = c(0, 100), expand = c(0, 0), breaks = c(0, 50, 100)) + scale_x_continuous(limits = c(0, 44), expand = c(0, 0)) + labs(x = "Length of paid leave entitlement (months)") + labs(y = "Percent of income paid (average over entitlement period)") + labs(title = "Total paid leave available to mothers in the OECD") + * labs(subtitle = "Countries rank ordered by paid leave full rate equivalent (blue rectangular area)\nVisualization: Gina Reynolds | Data source: OECD.org ") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_25-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = paid_leave_months) + aes(y = `Total paid leave avg payment rate (%)`) + aes(xmin = 0) + aes(xmax = paid_leave_months) + aes(ymin = 0) + aes(ymax = `Total paid leave avg payment rate (%)`) + facet_wrap(fct_inorder(rank_name) ~ .) + geom_rect(fill = "blue", alpha = .2) + aes(yend = 0) + aes(xend = 0) + geom_segment( aes(yend = `Total paid leave avg payment rate (%)`), lty = "dashed") + geom_segment(aes(xend = paid_leave_months), lty = "dashed") + scale_y_continuous(limits = c(0, 100), expand = c(0, 0), breaks = c(0, 50, 100)) + scale_x_continuous(limits = c(0, 44), expand = c(0, 0)) + labs(x = "Length of paid leave entitlement (months)") + labs(y = "Percent of income paid (average over entitlement period)") + labs(title = "Total paid leave available to mothers in the OECD") + labs(subtitle = "Countries rank ordered by paid leave full rate equivalent (blue rectangular area)\nVisualization: Gina Reynolds | Data source: OECD.org ") + * theme_bw(base_size = 12) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_parent_leave_26-1.png" width="80%" /> ]] --- name: traits # Traits A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Gender </th> <th style="text-align:left;"> Question_short </th> <th style="text-align:left;"> Rank (text) </th> <th style="text-align:right;"> Rank (number) </th> <th style="text-align:right;"> n </th> <th style="text-align:right;"> Percent </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Women </td> <td style="text-align:left;"> Sense of humor </td> <td style="text-align:left;"> Ranked fifth </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 1314.15 </td> <td style="text-align:right;"> 11.554714 </td> </tr> <tr> <td style="text-align:left;"> Men </td> <td style="text-align:left;"> Money </td> <td style="text-align:left;"> Ranked fourth </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 754.62 </td> <td style="text-align:right;"> 7.071332 </td> </tr> <tr> <td style="text-align:left;"> Women </td> <td style="text-align:left;"> Has similar interests </td> <td style="text-align:left;"> Ranked second </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 2101.13 </td> <td style="text-align:right;"> 18.433342 </td> </tr> <tr> <td style="text-align:left;"> Men </td> <td style="text-align:left;"> Personality </td> <td style="text-align:left;"> Ranked fifth </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 701.54 </td> <td style="text-align:right;"> 6.562005 </td> </tr> <tr> <td style="text-align:left;"> Women </td> <td style="text-align:left;"> Intellegence </td> <td style="text-align:left;"> Ranked third </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 2617.48 </td> <td style="text-align:right;"> 23.040406 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = world) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + * aes(x = Question_short_wrap) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + * aes(y = Percent) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + * aes(fill = `Rank (text)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + * facet_grid(Gender ~ .) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + * geom_col() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + geom_col() + * coord_flip() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + geom_col() + coord_flip() + * scale_fill_manual( * values = colorRampPalette( * RColorBrewer::brewer.pal(n = 9, name = "Purples"))(6), * guide = guide_legend(reverse = TRUE)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + geom_col() + coord_flip() + scale_fill_manual( values = colorRampPalette( RColorBrewer::brewer.pal(n = 9, name = "Purples"))(6), guide = guide_legend(reverse = TRUE)) + * labs(fill = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + geom_col() + coord_flip() + scale_fill_manual( values = colorRampPalette( RColorBrewer::brewer.pal(n = 9, name = "Purples"))(6), guide = guide_legend(reverse = TRUE)) + labs(fill = "") + * xlab("") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + geom_col() + coord_flip() + scale_fill_manual( values = colorRampPalette( RColorBrewer::brewer.pal(n = 9, name = "Purples"))(6), guide = guide_legend(reverse = TRUE)) + labs(fill = "") + xlab("") + * labs(title = "Why do I love thee? Let me rank the traits... \nHow 10,689 men and 11,370 women across 20 countries rank romantic partner trait importance") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = world) + aes(x = Question_short_wrap) + aes(y = Percent) + aes(fill = `Rank (text)`) + facet_grid(Gender ~ .) + geom_col() + coord_flip() + scale_fill_manual( values = colorRampPalette( RColorBrewer::brewer.pal(n = 9, name = "Purples"))(6), guide = guide_legend(reverse = TRUE)) + labs(fill = "") + xlab("") + labs(title = "Why do I love thee? Let me rank the traits... \nHow 10,689 men and 11,370 women across 20 countries rank romantic partner trait importance") + * labs(subtitle = "Data Source: @mattsmithetc and @YouGov | Design: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_traits_15-1.png" width="80%" /> ]] --- name: salaries # Salarys of Trump and Obama White House Employees The data set, originally reported on in an NPR article, shows the difference in the distribution of salaries for the Obama and early Trump White House. First I plot a histogram of each administration. Then I also contrast boxplots for each administration; the data points are overlayed, jittered to the widths of the boxplots. Plotly is used to make the graph interactive; mousing over will allow you to see who the point represents, their job description and exactly how much they are paid. A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> ADMINISTRATION </th> <th style="text-align:left;"> NAME </th> <th style="text-align:left;"> STATUS </th> <th style="text-align:right;"> SALARY </th> <th style="text-align:left;"> PAY BASIS </th> <th style="text-align:left;"> POSITION TITLE </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Trump </td> <td style="text-align:left;"> Jones, Sidney L. </td> <td style="text-align:left;"> Employee </td> <td style="text-align:right;"> 47576 </td> <td style="text-align:left;"> Per Annum </td> <td style="text-align:left;"> INFORMATION SERVICES OPERATOR </td> </tr> <tr> <td style="text-align:left;"> Obama </td> <td style="text-align:left;"> Mehrbani, Rodin A. </td> <td style="text-align:left;"> Employee </td> <td style="text-align:right;"> 172200 </td> <td style="text-align:left;"> Per Annum </td> <td style="text-align:left;"> ASSISTANT TO THE PRESIDENT AND DIRECTOR OF PRESIDENTIAL PERSONNEL </td> </tr> <tr> <td style="text-align:left;"> Obama </td> <td style="text-align:left;"> Smart, Kelly J. </td> <td style="text-align:left;"> Employee </td> <td style="text-align:right;"> 55000 </td> <td style="text-align:left;"> Per Annum </td> <td style="text-align:left;"> ASSOCIATE DIGITAL PRODUCER </td> </tr> <tr> <td style="text-align:left;"> Obama </td> <td style="text-align:left;"> Sullivan, Brendan C. </td> <td style="text-align:left;"> Employee </td> <td style="text-align:right;"> 50730 </td> <td style="text-align:left;"> Per Annum </td> <td style="text-align:left;"> ADVANCE LEAD </td> </tr> <tr> <td style="text-align:left;"> Obama </td> <td style="text-align:left;"> Etienne, Ashley D. </td> <td style="text-align:left;"> Employee </td> <td style="text-align:right;"> 104524 </td> <td style="text-align:left;"> Per Annum </td> <td style="text-align:left;"> SPECIAL ASSISTANT TO THE PRESIDENT AND CABINET COMMUNICATIONS DIRECTOR </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(both_data) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + * aes(x = ADMINISTRATION) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + * aes(y = SALARY) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + * geom_jitter(alpha = .5, * height = 0, * width = .25) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + * aes(col = ADMINISTRATION) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + * geom_boxplot(alpha = .25) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + * aes(fill = ADMINISTRATION) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + aes(fill = ADMINISTRATION) + * scale_colour_manual(values = * c("blue", "red")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + aes(fill = ADMINISTRATION) + scale_colour_manual(values = c("blue", "red")) + * scale_fill_manual(values = * c("blue", "red")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + aes(fill = ADMINISTRATION) + scale_colour_manual(values = c("blue", "red")) + scale_fill_manual(values = c("blue", "red")) + * theme_bw() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + aes(fill = ADMINISTRATION) + scale_colour_manual(values = c("blue", "red")) + scale_fill_manual(values = c("blue", "red")) + theme_bw() + * labs(title = "Obama and Trump White House Salaries as of early 2017") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + aes(fill = ADMINISTRATION) + scale_colour_manual(values = c("blue", "red")) + scale_fill_manual(values = c("blue", "red")) + theme_bw() + labs(title = "Obama and Trump White House Salaries as of early 2017") + * labs(subtitle = "Data source: NPR via #MakeoverMonday") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(both_data) + aes(x = ADMINISTRATION) + aes(y = SALARY) + geom_jitter(alpha = .5, height = 0, width = .25) + aes(col = ADMINISTRATION) + geom_boxplot(alpha = .25) + aes(fill = ADMINISTRATION) + scale_colour_manual(values = c("blue", "red")) + scale_fill_manual(values = c("blue", "red")) + theme_bw() + labs(title = "Obama and Trump White House Salaries as of early 2017") + labs(subtitle = "Data source: NPR via #MakeoverMonday") + * labs(caption = "Visualization: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_white_house_17-1.png" width="80%" /> ]] --- name: wintergamemedals # Winter Games A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> Year </th> <th style="text-align:left;"> Sport </th> <th style="text-align:left;"> Event </th> <th style="text-align:left;"> Country </th> <th style="text-align:left;"> Gender </th> <th style="text-align:right;"> Medal Rank </th> <th style="text-align:left;"> Medal </th> <th style="text-align:left;"> Name of Athlete or Team </th> <th style="text-align:right;"> Age of Athlete </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 1988 </td> <td style="text-align:left;"> Alpine Skiing </td> <td style="text-align:left;"> Men's Slalom </td> <td style="text-align:left;"> West Germany </td> <td style="text-align:left;"> Men </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> silver </td> <td style="text-align:left;"> Frank Wörndl </td> <td style="text-align:right;"> 28 </td> </tr> <tr> <td style="text-align:right;"> 1972 </td> <td style="text-align:left;"> Cross-Country Skiing </td> <td style="text-align:left;"> Men's 15 Kilometers </td> <td style="text-align:left;"> Soviet Union </td> <td style="text-align:left;"> Men </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> silver </td> <td style="text-align:left;"> Fyodor Simashov </td> <td style="text-align:right;"> 26 </td> </tr> <tr> <td style="text-align:right;"> 2010 </td> <td style="text-align:left;"> Speedskating </td> <td style="text-align:left;"> Women's Team Pursuit (6 laps) </td> <td style="text-align:left;"> Japan </td> <td style="text-align:left;"> Women </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> silver </td> <td style="text-align:left;"> Japan </td> <td style="text-align:right;"> NA </td> </tr> <tr> <td style="text-align:right;"> 1994 </td> <td style="text-align:left;"> Speedskating </td> <td style="text-align:left;"> Men's 1,500 Meters </td> <td style="text-align:left;"> Norway </td> <td style="text-align:left;"> Men </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> gold </td> <td style="text-align:left;"> Johann Olav Koss </td> <td style="text-align:right;"> 25 </td> </tr> <tr> <td style="text-align:right;"> 2002 </td> <td style="text-align:left;"> Alpine Skiing </td> <td style="text-align:left;"> Women's Combined </td> <td style="text-align:left;"> Germany </td> <td style="text-align:left;"> Women </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> bronze </td> <td style="text-align:left;"> Martina Ertl-Renz </td> <td style="text-align:right;"> 28 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = dta) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + * aes(x = Year) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + * aes(y = percent_medals) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = percent_medals) + * geom_line() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = percent_medals) + geom_line() + * facet_wrap(~ Country) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = percent_medals) + geom_line() + facet_wrap(~ Country) + * labs(y = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = percent_medals) + geom_line() + facet_wrap(~ Country) + labs(y = "") + * labs(title = "Number of Winter Olympic Medals among 16 most winning countries, 1948-2014") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = percent_medals) + geom_line() + facet_wrap(~ Country) + labs(y = "") + labs(title = "Number of Winter Olympic Medals among 16 most winning countries, 1948-2014") + * labs(caption = "Vis: @EvaMaeRey | Source: Sports-Reference.com") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dta) + aes(x = Year) + aes(y = percent_medals) + geom_line() + facet_wrap(~ Country) + labs(y = "") + labs(title = "Number of Winter Olympic Medals among 16 most winning countries, 1948-2014") + labs(caption = "Vis: @EvaMaeRey | Source: Sports-Reference.com") + * theme_minimal() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_countries_games_9-1.png" width="80%" /> ]] --- A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> Year </th> <th style="text-align:left;"> Sport </th> <th style="text-align:left;"> Event </th> <th style="text-align:left;"> Country </th> <th style="text-align:left;"> Gender </th> <th style="text-align:right;"> Medal Rank </th> <th style="text-align:left;"> Medal </th> <th style="text-align:left;"> Name of Athlete or Team </th> <th style="text-align:right;"> Age of Athlete </th> <th style="text-align:left;"> cold_war </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 1976 </td> <td style="text-align:left;"> Luge </td> <td style="text-align:left;"> Women's Singles </td> <td style="text-align:left;"> East Germany </td> <td style="text-align:left;"> Women </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> silver </td> <td style="text-align:left;"> Ute Rührold </td> <td style="text-align:right;"> 21 </td> <td style="text-align:left;"> East Germany </td> </tr> <tr> <td style="text-align:right;"> 2014 </td> <td style="text-align:left;"> Speedskating </td> <td style="text-align:left;"> Women's 1,500 Meters </td> <td style="text-align:left;"> Netherlands </td> <td style="text-align:left;"> Women </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> gold </td> <td style="text-align:left;"> Jorien Ter Mors </td> <td style="text-align:right;"> 24 </td> <td style="text-align:left;"> A </td> </tr> <tr> <td style="text-align:right;"> 1956 </td> <td style="text-align:left;"> Speedskating </td> <td style="text-align:left;"> Men's 1,500 Meters </td> <td style="text-align:left;"> Soviet Union </td> <td style="text-align:left;"> Men </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> gold </td> <td style="text-align:left;"> Yury Mikhaylov </td> <td style="text-align:right;"> 25 </td> <td style="text-align:left;"> Soviet Union </td> </tr> <tr> <td style="text-align:right;"> 1964 </td> <td style="text-align:left;"> Cross-Country Skiing </td> <td style="text-align:left;"> Women's 3 × 5-Kilometer Relay </td> <td style="text-align:left;"> Soviet Union </td> <td style="text-align:left;"> Women </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> gold </td> <td style="text-align:left;"> Soviet Union </td> <td style="text-align:right;"> NA </td> <td style="text-align:left;"> Soviet Union </td> </tr> <tr> <td style="text-align:right;"> 1960 </td> <td style="text-align:left;"> Speedskating </td> <td style="text-align:left;"> Men's 5,000 Meters </td> <td style="text-align:left;"> Norway </td> <td style="text-align:left;"> Men </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> silver </td> <td style="text-align:left;"> Knut Johannesen </td> <td style="text-align:right;"> 26 </td> <td style="text-align:left;"> A </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(dta) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + * aes(x = Year) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + * aes(y = `Age of Athlete`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + * facet_wrap(~ Sport, scales = "free_y", nrow = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + * geom_jitter(mapping = aes(col = fct_inorder(Medal)), * width = 1, height = .5, size = 1) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + * geom_smooth(col = "grey30") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + * annotate(geom = "ribbon", x = c(1945,2016), * ymin = 20, ymax = 30, * alpha = .1, fill = "blue") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + * geom_hline(yintercept = c(20, 30), lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + * geom_hline(yintercept = c(25), lty = "dashed") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + geom_hline(yintercept = c(25), lty = "dashed") + * scale_color_manual(values = c("goldenrod3", "grey40", "goldenrod4")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + geom_hline(yintercept = c(25), lty = "dashed") + scale_color_manual(values = c("goldenrod3", "grey40", "goldenrod4")) + * labs(x = "", col = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + geom_hline(yintercept = c(25), lty = "dashed") + scale_color_manual(values = c("goldenrod3", "grey40", "goldenrod4")) + labs(x = "", col = "") + * labs(title = "Young and old at the Winter Olympics: medalists' declared ages have risen in recent years") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + geom_hline(yintercept = c(25), lty = "dashed") + scale_color_manual(values = c("goldenrod3", "grey40", "goldenrod4")) + labs(x = "", col = "") + labs(title = "Young and old at the Winter Olympics: medalists' declared ages have risen in recent years") + * labs(subtitle = "Includes individual sports that have been in Olympic since 1965") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + geom_hline(yintercept = c(25), lty = "dashed") + scale_color_manual(values = c("goldenrod3", "grey40", "goldenrod4")) + labs(x = "", col = "") + labs(title = "Young and old at the Winter Olympics: medalists' declared ages have risen in recent years") + labs(subtitle = "Includes individual sports that have been in Olympic since 1965") + * labs(caption = "Source: Sports-Reference.com | Vis: Gina Reynolds @EvaMaeRey \nValues 'jittered' to reduce overplotting") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(dta) + aes(x = Year) + aes(y = `Age of Athlete`) + facet_wrap(~ Sport, scales = "free_y", nrow = 2) + geom_jitter(mapping = aes(col = fct_inorder(Medal)), width = 1, height = .5, size = 1) + geom_smooth(col = "grey30") + annotate(geom = "ribbon", x = c(1945,2016), ymin = 20, ymax = 30, alpha = .1, fill = "blue") + geom_hline(yintercept = c(20, 30), lty = "dotted") + geom_hline(yintercept = c(25), lty = "dashed") + scale_color_manual(values = c("goldenrod3", "grey40", "goldenrod4")) + labs(x = "", col = "") + labs(title = "Young and old at the Winter Olympics: medalists' declared ages have risen in recent years") + labs(subtitle = "Includes individual sports that have been in Olympic since 1965") + labs(caption = "Source: Sports-Reference.com | Vis: Gina Reynolds @EvaMaeRey \nValues 'jittered' to reduce overplotting") + * theme_bw(base_size = 13) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_winter_games_18-1.png" width="80%" /> ]] --- name: brexit # Brexit This visualization challenge was a proposed makeover for a Financial Times visualization focusing on relative economic growth in G7 countries, with an emphasis on growth in the UK, focusing especially since Brexit. The visualization I present here is not what I created at the time of the challenge; instead it is inspired by Alan Smith a data journalist at the Financial Times, who created a really compelling visualization a couple of months after #MakeoverMonday's treatment. I try to recreate his plot - which uses a ribbon to contain all G7 countries, and plot the UK's stats thereover. This declutters the graph, and makes you focus on where the UK falls among other countries, without being needlessly specific about those countries; the data story isn't about them anyway, might be Smith's thinking. My graph actually lightly traces economic growth in other countries, but deemphasizes their importance, like Smith. A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Country </th> <th style="text-align:right;"> Year </th> <th style="text-align:right;"> Quarter </th> <th style="text-align:left;"> Date (start of quarter) </th> <th style="text-align:right;"> Percentage change from previous period </th> <th style="text-align:left;"> Date (start o quarter) </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> CAN </td> <td style="text-align:right;"> 2013 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> 2013-04-01 </td> <td style="text-align:right;"> 0.648283 </td> <td style="text-align:left;"> 2013-04-01 </td> </tr> <tr> <td style="text-align:left;"> JPN </td> <td style="text-align:right;"> 2010 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> 2010-04-01 </td> <td style="text-align:right;"> 0.983190 </td> <td style="text-align:left;"> 2010-04-01 </td> </tr> <tr> <td style="text-align:left;"> ITA </td> <td style="text-align:right;"> 2012 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 2012-07-01 </td> <td style="text-align:right;"> -0.470006 </td> <td style="text-align:left;"> 2012-07-01 </td> </tr> <tr> <td style="text-align:left;"> FRA </td> <td style="text-align:right;"> 2012 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> 2012-01-01 </td> <td style="text-align:right;"> 0.070486 </td> <td style="text-align:left;"> 2012-01-01 </td> </tr> <tr> <td style="text-align:left;"> JPN </td> <td style="text-align:right;"> 2015 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 2015-07-01 </td> <td style="text-align:right;"> 0.171346 </td> <td style="text-align:left;"> 2015-07-01 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = data) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + * aes(x = `Date (start of quarter)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + * aes(y = `Percentage change from previous period`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + * facet_wrap(~ Country) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + facet_wrap(~ Country) + * geom_line() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + facet_wrap(~ Country) + geom_line() + * geom_hline(yintercept = 0, col = "grey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + facet_wrap(~ Country) + geom_line() + geom_hline(yintercept = 0, col = "grey") + * geom_vline(xintercept = as.numeric(as.POSIXct("2016-06-23")), lty = "dashed") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + facet_wrap(~ Country) + geom_line() + geom_hline(yintercept = 0, col = "grey") + geom_vline(xintercept = as.numeric(as.POSIXct("2016-06-23")), lty = "dashed") + * labs(title = "Quarterly GDP Growth in Relation to Brexit Vote") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + facet_wrap(~ Country) + geom_line() + geom_hline(yintercept = 0, col = "grey") + geom_vline(xintercept = as.numeric(as.POSIXct("2016-06-23")), lty = "dashed") + labs(title = "Quarterly GDP Growth in Relation to Brexit Vote") + * labs(subtitle = "Source: OECD") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1_9-1.png" width="80%" /> ]] --- A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Country </th> <th style="text-align:right;"> Year </th> <th style="text-align:right;"> Quarter </th> <th style="text-align:left;"> Date (start of quarter) </th> <th style="text-align:right;"> Percentage change from previous period </th> <th style="text-align:left;"> Date (start o quarter) </th> <th style="text-align:right;"> min_ </th> <th style="text-align:right;"> max_ </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> USA </td> <td style="text-align:right;"> 2017 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> 2017-01-01 </td> <td style="text-align:right;"> 0.307393 </td> <td style="text-align:left;"> 2017-01-01 </td> <td style="text-align:right;"> 0.211890 </td> <td style="text-align:right;"> 0.910663 </td> </tr> <tr> <td style="text-align:left;"> ITA </td> <td style="text-align:right;"> 2017 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:left;"> 2017-01-01 </td> <td style="text-align:right;"> 0.439413 </td> <td style="text-align:left;"> 2017-01-01 </td> <td style="text-align:right;"> 0.211890 </td> <td style="text-align:right;"> 0.910663 </td> </tr> <tr> <td style="text-align:left;"> ITA </td> <td style="text-align:right;"> 2011 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 2011-07-01 </td> <td style="text-align:right;"> -0.468615 </td> <td style="text-align:left;"> 2011-07-01 </td> <td style="text-align:right;"> -0.468615 </td> <td style="text-align:right;"> 2.312151 </td> </tr> <tr> <td style="text-align:left;"> CAN </td> <td style="text-align:right;"> 2011 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:left;"> 2011-04-01 </td> <td style="text-align:right;"> 0.189951 </td> <td style="text-align:left;"> 2011-04-01 </td> <td style="text-align:right;"> -0.544269 </td> <td style="text-align:right;"> 0.727759 </td> </tr> <tr> <td style="text-align:left;"> CAN </td> <td style="text-align:right;"> 2016 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 2016-07-01 </td> <td style="text-align:right;"> 1.021803 </td> <td style="text-align:left;"> 2016-07-01 </td> <td style="text-align:right;"> 0.185529 </td> <td style="text-align:right;"> 1.021803 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = data) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + * aes(x = `Date (start of quarter)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + * aes(y = `Percentage change from previous period`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + * aes(ymin = min_) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + * aes(ymax = max_) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + * geom_hline(yintercept = 0, col = "grey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + * geom_ribbon(alpha = .2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + geom_ribbon(alpha = .2) + * geom_line(aes(col = Country), alpha = .2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + geom_ribbon(alpha = .2) + geom_line(aes(col = Country), alpha = .2) + * geom_line(data = data_gbr, col = "black") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + geom_ribbon(alpha = .2) + geom_line(aes(col = Country), alpha = .2) + geom_line(data = data_gbr, col = "black") + * geom_vline(xintercept = * as.numeric(as.POSIXct("2016-06-23")), * lty = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + geom_ribbon(alpha = .2) + geom_line(aes(col = Country), alpha = .2) + geom_line(data = data_gbr, col = "black") + geom_vline(xintercept = as.numeric(as.POSIXct("2016-06-23")), lty = 2) + * annotate(geom = "text", * x = as.POSIXct("2016-04-23"), y = 1.5, * label = "Brexit Vote", angle = 90) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + geom_ribbon(alpha = .2) + geom_line(aes(col = Country), alpha = .2) + geom_line(data = data_gbr, col = "black") + geom_vline(xintercept = as.numeric(as.POSIXct("2016-06-23")), lty = 2) + annotate(geom = "text", x = as.POSIXct("2016-04-23"), y = 1.5, label = "Brexit Vote", angle = 90) + * labs(title = "Quarterly GDP Growth of G7 in Relation to Brexit Vote", * subtitle = "Source: OECD", col = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = `Date (start of quarter)`) + aes(y = `Percentage change from previous period`) + aes(ymin = min_) + aes(ymax = max_) + geom_hline(yintercept = 0, col = "grey") + geom_ribbon(alpha = .2) + geom_line(aes(col = Country), alpha = .2) + geom_line(data = data_gbr, col = "black") + geom_vline(xintercept = as.numeric(as.POSIXct("2016-06-23")), lty = 2) + annotate(geom = "text", x = as.POSIXct("2016-04-23"), y = 1.5, label = "Brexit Vote", angle = 90) + labs(title = "Quarterly GDP Growth of G7 in Relation to Brexit Vote", subtitle = "Source: OECD", col = "") + * theme_bw() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_brexit_18-1.png" width="80%" /> ]] --- name: britishburgers # Curry in London This visualization task seemed to get at the question: Does where you eat matter? The data was the cost of identical menu items at different locations of the same restaurant, the Wetherspoon, around the UK. First, I mapped the cost of a single menu item, the Empire Burger, across the UK. Then, I calculated the distance from Wetherspoon restaurants from the Big Ben, and plotted prices as a function of this distance -- plotting only the restaurants in a 10 kilometer radius. A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Name </th> <th style="text-align:left;"> Location </th> <th style="text-align:right;"> Latitude </th> <th style="text-align:right;"> Longitude </th> <th style="text-align:right;"> Empire State Burger </th> <th style="text-align:right;"> Chicken Tikka </th> <th style="text-align:right;"> Gammon afternoon deal </th> <th style="text-align:right;"> Chocolate Brownie </th> <th style="text-align:right;"> Doom Bar </th> <th style="text-align:right;"> Birra Moretti </th> <th style="text-align:right;"> Porn Star at 2 x £12 </th> <th style="text-align:right;"> Porn Star (glass) </th> <th style="text-align:right;"> MEAL </th> <th style="text-align:left;"> Notes </th> <th style="text-align:right;"> Moretti as a % of a tikka </th> <th style="text-align:right;"> Moretti as % of burger </th> <th style="text-align:left;"> PRICE BUCKETS </th> <th style="text-align:right;"> Food cost £ </th> <th style="text-align:right;"> Drink cost £ </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> The William Stead </td> <td style="text-align:left;"> Darlington </td> <td style="text-align:right;"> 54.52567 </td> <td style="text-align:right;"> -1.552765 </td> <td style="text-align:right;"> 8.75 </td> <td style="text-align:right;"> 7.19 </td> <td style="text-align:right;"> 5.90 </td> <td style="text-align:right;"> 3.85 </td> <td style="text-align:right;"> 2.15 </td> <td style="text-align:right;"> 2.99 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> 6.2 </td> <td style="text-align:right;"> 24.93 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4158554 </td> <td style="text-align:right;"> 0.3417143 </td> <td style="text-align:left;"> £25.20- </td> <td style="text-align:right;"> 15.94 </td> <td style="text-align:right;"> 5.14 </td> </tr> <tr> <td style="text-align:left;"> The Christopher Creeke </td> <td style="text-align:left;"> Bournemouth </td> <td style="text-align:right;"> 50.72238 </td> <td style="text-align:right;"> -1.865745 </td> <td style="text-align:right;"> 8.75 </td> <td style="text-align:right;"> 6.40 </td> <td style="text-align:right;"> 5.99 </td> <td style="text-align:right;"> 3.40 </td> <td style="text-align:right;"> 2.29 </td> <td style="text-align:right;"> 3.19 </td> <td style="text-align:right;"> 6.3 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> 24.03 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4984375 </td> <td style="text-align:right;"> 0.3645714 </td> <td style="text-align:left;"> £25.20- </td> <td style="text-align:right;"> 15.15 </td> <td style="text-align:right;"> 5.48 </td> </tr> <tr> <td style="text-align:left;"> The King Johns Tavern </td> <td style="text-align:left;"> Hartlepool </td> <td style="text-align:right;"> 54.68459 </td> <td style="text-align:right;"> -1.215545 </td> <td style="text-align:right;"> 8.75 </td> <td style="text-align:right;"> 7.19 </td> <td style="text-align:right;"> 5.90 </td> <td style="text-align:right;"> 3.85 </td> <td style="text-align:right;"> 1.99 </td> <td style="text-align:right;"> 3.09 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> 6.3 </td> <td style="text-align:right;"> 24.87 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4297636 </td> <td style="text-align:right;"> 0.3531429 </td> <td style="text-align:left;"> £25.20- </td> <td style="text-align:right;"> 15.94 </td> <td style="text-align:right;"> 5.08 </td> </tr> <tr> <td style="text-align:left;"> The Chief Justice of the Common Pleas </td> <td style="text-align:left;"> Keswick </td> <td style="text-align:right;"> 54.60187 </td> <td style="text-align:right;"> -3.137909 </td> <td style="text-align:right;"> 8.70 </td> <td style="text-align:right;"> 7.85 </td> <td style="text-align:right;"> 5.70 </td> <td style="text-align:right;"> 3.80 </td> <td style="text-align:right;"> 2.59 </td> <td style="text-align:right;"> 3.09 </td> <td style="text-align:right;"> 6.3 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> 26.03 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.3936306 </td> <td style="text-align:right;"> 0.3551724 </td> <td style="text-align:left;"> £25.21+ </td> <td style="text-align:right;"> 16.55 </td> <td style="text-align:right;"> 5.68 </td> </tr> <tr> <td style="text-align:left;"> The Square Bottle </td> <td style="text-align:left;"> Chester </td> <td style="text-align:right;"> 53.19140 </td> <td style="text-align:right;"> -2.884303 </td> <td style="text-align:right;"> 9.10 </td> <td style="text-align:right;"> 7.29 </td> <td style="text-align:right;"> 5.90 </td> <td style="text-align:right;"> 3.85 </td> <td style="text-align:right;"> 2.59 </td> <td style="text-align:right;"> 3.25 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> 5.9 </td> <td style="text-align:right;"> 26.08 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4458162 </td> <td style="text-align:right;"> 0.3571429 </td> <td style="text-align:left;"> £25.21+ </td> <td style="text-align:right;"> 16.39 </td> <td style="text-align:right;"> 5.84 </td> </tr> </tbody> </table> A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> long </th> <th style="text-align:right;"> lat </th> <th style="text-align:right;"> group </th> <th style="text-align:right;"> order </th> <th style="text-align:left;"> region </th> <th style="text-align:left;"> subregion </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 22.58242 </td> <td style="text-align:right;"> 48.134033 </td> <td style="text-align:right;"> 691 </td> <td style="text-align:right;"> 46543 </td> <td style="text-align:left;"> Hungary </td> <td style="text-align:left;"> NA </td> </tr> <tr> <td style="text-align:right;"> 72.18095 </td> <td style="text-align:right;"> 41.118458 </td> <td style="text-align:right;"> 904 </td> <td style="text-align:right;"> 57427 </td> <td style="text-align:left;"> Kyrgyzstan </td> <td style="text-align:left;"> NA </td> </tr> <tr> <td style="text-align:right;"> -59.78564 </td> <td style="text-align:right;"> -80.001076 </td> <td style="text-align:right;"> 29 </td> <td style="text-align:right;"> 2465 </td> <td style="text-align:left;"> Antarctica </td> <td style="text-align:left;"> Henry Ice Rise </td> </tr> <tr> <td style="text-align:right;"> -53.75435 </td> <td style="text-align:right;"> 69.260155 </td> <td style="text-align:right;"> 651 </td> <td style="text-align:right;"> 43146 </td> <td style="text-align:left;"> Greenland </td> <td style="text-align:left;"> Quqertarsuaq </td> </tr> <tr> <td style="text-align:right;"> 148.79179 </td> <td style="text-align:right;"> -9.089453 </td> <td style="text-align:right;"> 1195 </td> <td style="text-align:right;"> 73693 </td> <td style="text-align:left;"> Papua New Guinea </td> <td style="text-align:left;"> NA </td> </tr> </tbody> </table> --- --- class: split-40 count: false .column[.content[ ```r *ggplot(data = data_UK) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + * aes(x = long) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + * aes(y = lat) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + * aes(group = group) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + * geom_polygon(fill = "white") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + * coord_equal() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + * scale_fill_viridis_c(option = "viridis") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + scale_fill_viridis_c(option = "viridis") + * geom_point(data = data0, mapping = aes(x = Longitude, y = Latitude, group = NULL, fill = `Empire State Burger`), colour = "black", shape = 21, stroke = 1, alpha = .5, size = 3) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + scale_fill_viridis_c(option = "viridis") + geom_point(data = data0, mapping = aes(x = Longitude, y = Latitude, group = NULL, fill = `Empire State Burger`), colour = "black", shape = 21, stroke = 1, alpha = .5, size = 3) + * labs(fill = "Price\n(Pounds)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + scale_fill_viridis_c(option = "viridis") + geom_point(data = data0, mapping = aes(x = Longitude, y = Latitude, group = NULL, fill = `Empire State Burger`), colour = "black", shape = 21, stroke = 1, alpha = .5, size = 3) + labs(fill = "Price\n(Pounds)") + * labs(title = "Wetherspoon Empire State Burger Price") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + scale_fill_viridis_c(option = "viridis") + geom_point(data = data0, mapping = aes(x = Longitude, y = Latitude, group = NULL, fill = `Empire State Burger`), colour = "black", shape = 21, stroke = 1, alpha = .5, size = 3) + labs(fill = "Price\n(Pounds)") + labs(title = "Wetherspoon Empire State Burger Price") + * labs(subtitle = "@EvaMaeRey | source: data.worldbank.org") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + scale_fill_viridis_c(option = "viridis") + geom_point(data = data0, mapping = aes(x = Longitude, y = Latitude, group = NULL, fill = `Empire State Burger`), colour = "black", shape = 21, stroke = 1, alpha = .5, size = 3) + labs(fill = "Price\n(Pounds)") + labs(title = "Wetherspoon Empire State Burger Price") + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org") + * theme_void() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data_UK) + aes(x = long) + aes(y = lat) + aes(group = group) + geom_polygon(fill = "white") + coord_equal() + scale_fill_viridis_c(option = "viridis") + geom_point(data = data0, mapping = aes(x = Longitude, y = Latitude, group = NULL, fill = `Empire State Burger`), colour = "black", shape = 21, stroke = 1, alpha = .5, size = 3) + labs(fill = "Price\n(Pounds)") + labs(title = "Wetherspoon Empire State Burger Price") + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org") + theme_void() + * theme(plot.background = element_rect(fill = "#e6e8ed")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_map_curry_13-1.png" width="80%" /> ]] --- name: britishfood A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Name </th> <th style="text-align:left;"> Location </th> <th style="text-align:right;"> Latitude </th> <th style="text-align:right;"> Longitude </th> <th style="text-align:left;"> Notes </th> <th style="text-align:right;"> Moretti as a % of a tikka </th> <th style="text-align:right;"> Moretti as % of burger </th> <th style="text-align:left;"> PRICE BUCKETS </th> <th style="text-align:right;"> Food cost £ </th> <th style="text-align:right;"> Drink cost £ </th> <th style="text-align:right;"> Kilometers from Big Ben </th> <th style="text-align:left;"> Item </th> <th style="text-align:right;"> Menu Item Price </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> The Bull's Head Hotel </td> <td style="text-align:left;"> Manchester </td> <td style="text-align:right;"> 53.47639 </td> <td style="text-align:right;"> -2.231713 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.3607595 </td> <td style="text-align:right;"> 0.3257143 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 16.65 </td> <td style="text-align:right;"> 5.14 </td> <td style="text-align:right;"> 261.6922 </td> <td style="text-align:left;"> Doom Bar </td> <td style="text-align:right;"> 2.29 </td> </tr> <tr> <td style="text-align:left;"> The Ward Jackson </td> <td style="text-align:left;"> Hartlepool </td> <td style="text-align:right;"> 54.68556 </td> <td style="text-align:right;"> -1.208599 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4297636 </td> <td style="text-align:right;"> 0.3639576 </td> <td style="text-align:left;"> £25.20- </td> <td style="text-align:right;"> 15.68 </td> <td style="text-align:right;"> 5.14 </td> <td style="text-align:right;"> 360.8391 </td> <td style="text-align:left;"> Birra Moretti </td> <td style="text-align:right;"> 3.09 </td> </tr> <tr> <td style="text-align:left;"> Chapel an Gansblydhen </td> <td style="text-align:left;"> Bodmin </td> <td style="text-align:right;"> 50.47103 </td> <td style="text-align:right;"> -4.723465 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.3915276 </td> <td style="text-align:right;"> 0.3407821 </td> <td style="text-align:left;"> £25.21+ </td> <td style="text-align:right;"> 16.74 </td> <td style="text-align:right;"> 5.34 </td> <td style="text-align:right;"> 343.4161 </td> <td style="text-align:left;"> Birra Moretti </td> <td style="text-align:right;"> 3.05 </td> </tr> <tr> <td style="text-align:left;"> The Great Central </td> <td style="text-align:left;"> Wilmslow Road </td> <td style="text-align:right;"> 53.44093 </td> <td style="text-align:right;"> -2.219457 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4256757 </td> <td style="text-align:right;"> 0.3600000 </td> <td style="text-align:left;"> £25.21+ </td> <td style="text-align:right;"> 16.15 </td> <td style="text-align:right;"> 5.44 </td> <td style="text-align:right;"> 257.9732 </td> <td style="text-align:left;"> Birra Moretti </td> <td style="text-align:right;"> 3.15 </td> </tr> <tr> <td style="text-align:left;"> The Counting House </td> <td style="text-align:left;"> Congleton </td> <td style="text-align:right;"> 53.16386 </td> <td style="text-align:right;"> -2.214653 </td> <td style="text-align:left;"> NA </td> <td style="text-align:right;"> 0.4175676 </td> <td style="text-align:right;"> 0.3531429 </td> <td style="text-align:left;"> £25.21+ </td> <td style="text-align:right;"> 16.15 </td> <td style="text-align:right;"> 5.38 </td> <td style="text-align:right;"> 233.0020 </td> <td style="text-align:left;"> Doom Bar </td> <td style="text-align:right;"> 2.29 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = dataLong) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + * aes(x = `Kilometers from Big Ben`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + * aes(y = `Menu Item Price`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + aes(y = `Menu Item Price`) + * facet_wrap(~ Item, scales = "free_y") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + aes(y = `Menu Item Price`) + facet_wrap(~ Item, scales = "free_y") + * geom_point() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + aes(y = `Menu Item Price`) + facet_wrap(~ Item, scales = "free_y") + geom_point() + * geom_smooth() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + aes(y = `Menu Item Price`) + facet_wrap(~ Item, scales = "free_y") + geom_point() + geom_smooth() + * xlim(c(0, 10)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + aes(y = `Menu Item Price`) + facet_wrap(~ Item, scales = "free_y") + geom_point() + geom_smooth() + xlim(c(0, 10)) + * labs(title = "Wetherspoon Pubs' Menu Item Prices v. Distance from Big Ben") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dataLong) + aes(x = `Kilometers from Big Ben`) + aes(y = `Menu Item Price`) + facet_wrap(~ Item, scales = "free_y") + geom_point() + geom_smooth() + xlim(c(0, 10)) + labs(title = "Wetherspoon Pubs' Menu Item Prices v. Distance from Big Ben") + * labs(subtitle = "Visualization: Gina Reynolds | Source: Financial Times Alphaville") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_away_from_ben_9-1.png" width="80%" /> ]] --- name: lifeexpect # Life Expectancy Increases To dramatically show the increases in life expectancy by country from 1960 to 2010, I plot the variable in 1960 versus itself in 2010. The line of equivilance (a 45% angle) is used as a reference and shows the result that you would see if there where no growth. The vertical distance from this line is the increase in life expectancy. I also superimpose a linear model on top of the scatter plot. You can see that the gains are greater for countries that started off with lower life expectancies. A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> Life Expectancy 1960 </th> <th style="text-align:left;"> Country Code </th> <th style="text-align:left;"> Country Name </th> <th style="text-align:left;"> Region </th> <th style="text-align:left;"> Income Group </th> <th style="text-align:right;"> Year </th> <th style="text-align:right;"> Life Expectancy 2010 </th> <th style="text-align:left;"> CountryName </th> <th style="text-align:right;"> squared </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 68.29954 </td> <td style="text-align:left;"> UKR </td> <td style="text-align:left;"> Ukraine </td> <td style="text-align:left;"> Europe & Central Asia </td> <td style="text-align:left;"> Lower middle income </td> <td style="text-align:right;"> 2010 </td> <td style="text-align:right;"> 70.26537 </td> <td style="text-align:left;"> Ukraine </td> <td style="text-align:right;"> 4664.827 </td> </tr> <tr> <td style="text-align:right;"> 48.85641 </td> <td style="text-align:left;"> CPV </td> <td style="text-align:left;"> Cabo Verde </td> <td style="text-align:left;"> Sub-Saharan Africa </td> <td style="text-align:left;"> Lower middle income </td> <td style="text-align:right;"> 2010 </td> <td style="text-align:right;"> 71.77454 </td> <td style="text-align:left;"> Cape Verde </td> <td style="text-align:right;"> 2386.949 </td> </tr> <tr> <td style="text-align:right;"> 58.36759 </td> <td style="text-align:left;"> KAZ </td> <td style="text-align:left;"> Kazakhstan </td> <td style="text-align:left;"> Europe & Central Asia </td> <td style="text-align:left;"> Upper middle income </td> <td style="text-align:right;"> 2010 </td> <td style="text-align:right;"> 68.29537 </td> <td style="text-align:left;"> Kazakhstan </td> <td style="text-align:right;"> 3406.775 </td> </tr> <tr> <td style="text-align:right;"> 33.22602 </td> <td style="text-align:left;"> AGO </td> <td style="text-align:left;"> Angola </td> <td style="text-align:left;"> Sub-Saharan Africa </td> <td style="text-align:left;"> Lower middle income </td> <td style="text-align:right;"> 2010 </td> <td style="text-align:right;"> 58.14112 </td> <td style="text-align:left;"> Angola </td> <td style="text-align:right;"> 1103.969 </td> </tr> <tr> <td style="text-align:right;"> 43.98356 </td> <td style="text-align:left;"> UGA </td> <td style="text-align:left;"> Uganda </td> <td style="text-align:left;"> Sub-Saharan Africa </td> <td style="text-align:left;"> Low income </td> <td style="text-align:right;"> 2010 </td> <td style="text-align:right;"> 57.07763 </td> <td style="text-align:left;"> Uganda </td> <td style="text-align:right;"> 1934.554 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(compare) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + * aes(x = `Life Expectancy 1960`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + * aes(y = `Life Expectancy 2010`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + * geom_point() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + * geom_smooth(se = F, method = "lm") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + * geom_abline(slope = 1, intercept = 0, lty = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + * aes(xend = `Life Expectancy 1960`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + * aes(yend = `Life Expectancy 1960`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + * geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + * geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + * scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + * geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + * geom_point() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + geom_point() + * labs(subtitle = "@EvaMaeRey | source: data.worldbank.org", size = .7) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + geom_point() + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org", size = .7) + * labs(title = "Life Expectancy at Birth by Country") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + geom_point() + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org", size = .7) + labs(title = "Life Expectancy at Birth by Country") + * labs(col = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + geom_point() + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org", size = .7) + labs(title = "Life Expectancy at Birth by Country") + labs(col = "") + * theme(legend.title = element_blank()) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + geom_point() + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org", size = .7) + labs(title = "Life Expectancy at Birth by Country") + labs(col = "") + theme(legend.title = element_blank()) + * theme_bw() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(compare) + aes(x = `Life Expectancy 1960`) + aes(y = `Life Expectancy 2010`) + geom_point() + geom_smooth(se = F, method = "lm") + geom_abline(slope = 1, intercept = 0, lty = 2) + aes(xend = `Life Expectancy 1960`) + aes(yend = `Life Expectancy 1960`) + geom_segment(mapping = aes(col = "Gain from 1960 to 2010")) + geom_segment(mapping = aes(y = 0, col = "Country Expectancy in 1960")) + scale_color_manual( breaks = c("Gain from 1960 to 2010", "Country Expectancy in 1960"), values = c("grey59", "grey30", "grey30")) + geom_point(aes(y = `Life Expectancy 1960`), col = "grey30") + geom_point() + labs(subtitle = "@EvaMaeRey | source: data.worldbank.org", size = .7) + labs(title = "Life Expectancy at Birth by Country") + labs(col = "") + theme(legend.title = element_blank()) + theme_bw() + * xlim(c(20, 80)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_life_expect_19-1.png" width="80%" /> ]] --- name: myersbriggs # Myers Briggs This visualization is of prevelence of Myers Briggs type distributions within the US population. So the data allows one to look at the relationship betweeen the four Myers Briggs types. The challenge is how to display that in one visualization. My first idea was to use a mosaic plot. However, I came across advice from "The Perceptual Edge", that generally advised against the use of the mosaic plot, instead favoring a kind of nested bar plot. I tried to implement that. While I do think that the result is pretty, I think that it still requires a lot of the reader to interpret the graph. More annotation might alleviate this burden. A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> (E)xtroversion/(I)ntroversion </th> <th style="text-align:left;"> (S)ensing/I(N)tuition </th> <th style="text-align:left;"> (T)hinking/(F)eeling </th> <th style="text-align:left;"> (J)udging/(P)erceiving </th> <th style="text-align:right;"> Ratio in Population </th> <th style="text-align:right;"> count </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Extroversion </td> <td style="text-align:left;"> Sensing </td> <td style="text-align:left;"> Feeling </td> <td style="text-align:left;"> Judging </td> <td style="text-align:right;"> 0.123 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Extroversion </td> <td style="text-align:left;"> Intuition </td> <td style="text-align:left;"> Feeling </td> <td style="text-align:left;"> Perceiving </td> <td style="text-align:right;"> 0.081 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Introversion </td> <td style="text-align:left;"> Sensing </td> <td style="text-align:left;"> Feeling </td> <td style="text-align:left;"> Judging </td> <td style="text-align:right;"> 0.138 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Introversion </td> <td style="text-align:left;"> Intuition </td> <td style="text-align:left;"> Feeling </td> <td style="text-align:left;"> Perceiving </td> <td style="text-align:right;"> 0.044 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> Extroversion </td> <td style="text-align:left;"> Sensing </td> <td style="text-align:left;"> Thinking </td> <td style="text-align:left;"> Judging </td> <td style="text-align:right;"> 0.087 </td> <td style="text-align:right;"> 1 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + * aes(x = `(J)udging/(P)erceiving`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + * aes(fill = `(T)hinking/(F)eeling`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + * facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + * geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + * geom_bar(position = "dodge") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + * scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) + labs(x = "") + * labs(y = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) + labs(x = "") + labs(y = "") + * labs(fill = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) + labs(x = "") + labs(y = "") + labs(fill = "") + * labs(title = "Frequency of Myers-Briggs Types") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) + labs(x = "") + labs(y = "") + labs(fill = "") + labs(title = "Frequency of Myers-Briggs Types") + * labs(subtitle = "Expected among 1000 individuals | @evamaerey | Source: http://www.myersbriggs.org/") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = `(J)udging/(P)erceiving`) + aes(fill = `(T)hinking/(F)eeling`) + facet_grid(`(E)xtroversion/(I)ntroversion` ~ `(S)ensing/I(N)tuition`) + geom_rect(aes(x = NULL, y = NULL, xmin = mins, xmax = max, fill = `judging perceiving`), ymin = 0, ymax = 700, data = background) + geom_bar(position = "dodge") + scale_fill_manual(values = alpha(c("lightgrey", "darkgrey", "blue", "violet"), c(.3, .3, .6, .6))) + labs(x = "") + labs(y = "") + labs(fill = "") + labs(title = "Frequency of Myers-Briggs Types") + labs(subtitle = "Expected among 1000 individuals | @evamaerey | Source: http://www.myersbriggs.org/") + * theme_bw(base_size = 10, base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_myers_briggs_13-1.png" width="80%" /> ]] --- name: womensrepresentation # Officials' beliefs about women's representation The data provided is based on a small survey of elite officials in five less developed countries. The question that arrises from the data is: How well do elites know the conditions in their countries. In general, the elites overestimate women's representation. But this is not the case in Senegal, where there are gender quotas in the Parliament. Most elites therefore estimate that the representation is about equal with men. I jitter the responses of the elites horizontally to avoid overplotting. --- A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Country </th> <th style="text-align:left;"> Topic </th> <th style="text-align:right;"> value </th> <th style="text-align:left;"> value_type </th> <th style="text-align:right;"> alpha </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Indonesia </td> <td style="text-align:left;"> Share of seats held by women </td> <td style="text-align:right;"> 0.17 </td> <td style="text-align:left;"> Individual belief </td> <td style="text-align:right;"> 0.3 </td> </tr> <tr> <td style="text-align:left;"> Colombia </td> <td style="text-align:left;"> Share of seats held by women </td> <td style="text-align:right;"> 0.15 </td> <td style="text-align:left;"> Individual belief </td> <td style="text-align:right;"> 0.3 </td> </tr> <tr> <td style="text-align:left;"> Indonesia </td> <td style="text-align:left;"> Share of seats held by women </td> <td style="text-align:right;"> 0.10 </td> <td style="text-align:left;"> Individual belief </td> <td style="text-align:right;"> 0.3 </td> </tr> <tr> <td style="text-align:left;"> India </td> <td style="text-align:left;"> Share of seats held by women </td> <td style="text-align:right;"> 0.12 </td> <td style="text-align:left;"> Individual belief </td> <td style="text-align:right;"> 0.3 </td> </tr> <tr> <td style="text-align:left;"> Senegal </td> <td style="text-align:left;"> Share of seats held by women </td> <td style="text-align:right;"> 0.47 </td> <td style="text-align:left;"> Individual belief </td> <td style="text-align:right;"> 0.3 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = df_all) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + * aes(x = Country, y = value) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + * aes(col = fct_inorder(value_type)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + * aes(alpha = fct_inorder(value_type)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + * aes(shape = fct_inorder(value_type)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + * geom_jitter(width = .1, height = 0, size = 7) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + * geom_hline(yintercept = c(0, 100), col = "grey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + * geom_hline(yintercept = c(50), lty = 2, col = "grey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + * theme_bw(base_size = 12, base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + * scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + * scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + * scale_alpha_manual(name = "", values = c(1, .17, 1)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + * scale_shape_manual(name = "", values = c(8, 19, 8)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + scale_shape_manual(name = "", values = c(8, 19, 8)) + * annotate(geom = "text", x = 4.95, y = .70, label = str_wrap("Senegal's 2010 gender parity law means it leads among these countries.", 16), size = 3, hjust = 1) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + scale_shape_manual(name = "", values = c(8, 19, 8)) + annotate(geom = "text", x = 4.95, y = .70, label = str_wrap("Senegal's 2010 gender parity law means it leads among these countries.", 16), size = 3, hjust = 1) + * annotate(geom = "text", x = 5.05, y = .250, label = str_wrap("Officials seem to be aware of the law.", 10), size = 3, hjust = 0) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + scale_shape_manual(name = "", values = c(8, 19, 8)) + annotate(geom = "text", x = 4.95, y = .70, label = str_wrap("Senegal's 2010 gender parity law means it leads among these countries.", 16), size = 3, hjust = 1) + annotate(geom = "text", x = 5.05, y = .250, label = str_wrap("Officials seem to be aware of the law.", 10), size = 3, hjust = 0) + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + scale_shape_manual(name = "", values = c(8, 19, 8)) + annotate(geom = "text", x = 4.95, y = .70, label = str_wrap("Senegal's 2010 gender parity law means it leads among these countries.", 16), size = 3, hjust = 1) + annotate(geom = "text", x = 5.05, y = .250, label = str_wrap("Officials seem to be aware of the law.", 10), size = 3, hjust = 0) + labs(x = "") + * labs(y = "Seats held by women") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + scale_shape_manual(name = "", values = c(8, 19, 8)) + annotate(geom = "text", x = 4.95, y = .70, label = str_wrap("Senegal's 2010 gender parity law means it leads among these countries.", 16), size = 3, hjust = 1) + annotate(geom = "text", x = 5.05, y = .250, label = str_wrap("Officials seem to be aware of the law.", 10), size = 3, hjust = 0) + labs(x = "") + labs(y = "Seats held by women") + * labs(title = "Women in national parliaments in 2015 in five countries \nand officials' beliefs about representation") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = df_all) + aes(x = Country, y = value) + aes(col = fct_inorder(value_type)) + aes(alpha = fct_inorder(value_type)) + aes(shape = fct_inorder(value_type)) + geom_jitter(width = .1, height = 0, size = 7) + geom_hline(yintercept = c(0, 100), col = "grey") + geom_hline(yintercept = c(50), lty = 2, col = "grey") + theme_bw(base_size = 12, base_family = "Times") + scale_y_continuous(limits = c(0, 1), expand = c(0, 0), labels = scales::percent) + scale_colour_manual(name = "", values = c("darkblue", "goldenrod3", "goldenrod3")) + scale_alpha_manual(name = "", values = c(1, .17, 1)) + scale_shape_manual(name = "", values = c(8, 19, 8)) + annotate(geom = "text", x = 4.95, y = .70, label = str_wrap("Senegal's 2010 gender parity law means it leads among these countries.", 16), size = 3, hjust = 1) + annotate(geom = "text", x = 5.05, y = .250, label = str_wrap("Officials seem to be aware of the law.", 10), size = 3, hjust = 0) + labs(x = "") + labs(y = "Seats held by women") + labs(title = "Women in national parliaments in 2015 in five countries \nand officials' beliefs about representation") + * labs(subtitle = "Data Source: Equal Measures 2030 | Vis: Gina Reynolds @EvaMaeRey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_women_19-1.png" width="80%" /> ]] --- name: wine # Wine Wine production in Europe may have been volitile during the years plotted because of production control policies implemented by the EU. Particularly, the big three, Italy, France and Spain, saw a lot of volitility early in this period. ```r df <- readxl::read_xlsx("raw_data/Wine_Production_by_country.xlsx") %>% filter(Country != "World total") Europe <- c( "Italy", "France", "Spain", "Germany", "Portugal", "Romania", "Austria", "Greece", "Hungary" ) ``` ```r theme_opts <- theme( axis.title = element_blank(), strip.placement = "outside", axis.text.x = element_blank(), axis.ticks.x = element_blank(), strip.background = element_blank(), plot.caption = element_text(size = 10) ) ``` --- class: split-40 count: false .column[.content[ ```r * ggplot(df %>% filter(Country %in% Europe)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + * aes(x = Year) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + * aes(y = `Wine production in mhl`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + * facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + * geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + * geom_line(col = "black", lty = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + * scale_y_continuous(expand = c(0, 0)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + scale_y_continuous(expand = c(0, 0)) + * labs(fill = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + scale_y_continuous(expand = c(0, 0)) + labs(fill = "") + * labs(alpha = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + scale_y_continuous(expand = c(0, 0)) + labs(fill = "") + labs(alpha = "")+ * labs(title = "Wine production (mhl) in principle European markets, 2012-2016") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + scale_y_continuous(expand = c(0, 0)) + labs(fill = "") + labs(alpha = "")+ labs(title = "Wine production (mhl) in principle European markets, 2012-2016") + * labs(subtitle = "The EU program to regulate viticultural production ended upon the 2011/2012 harvest.") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + scale_y_continuous(expand = c(0, 0)) + labs(fill = "") + labs(alpha = "")+ labs(title = "Wine production (mhl) in principle European markets, 2012-2016") + labs(subtitle = "The EU program to regulate viticultural production ended upon the 2011/2012 harvest.") + * labs(caption = "Design: Gina Reynolds @EvaMaeRey \nData Source: International Organisation of Vine and Wine") # \nProduction volitility for top producers followed. ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df %>% filter(Country %in% Europe)) + aes(x = Year) + aes(y = `Wine production in mhl`) + facet_wrap(~ fct_inorder(Country), strip.position = "bottom", nrow = 1) + geom_col(aes(alpha = Year), position = "dodge", fill = "darkred", width = 1) + geom_line(col = "black", lty = 2) + scale_y_continuous(expand = c(0, 0)) + labs(fill = "") + labs(alpha = "")+ labs(title = "Wine production (mhl) in principle European markets, 2012-2016") + labs(subtitle = "The EU program to regulate viticultural production ended upon the 2011/2012 harvest.") + labs(caption = "Design: Gina Reynolds @EvaMaeRey \nData Source: International Organisation of Vine and Wine") + # \nProduction volitility for top producers followed. * theme_classic(base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wine_13-1.png" width="80%" /> ]] --- name: ice # Arctic Ice This visualization shows the trend in Arctic Ice Sea Extent, data from the National Snow and Ice Data Center. The definition for coverage is the case where at least 15 percent of the sea surface ice. The visualization shows melting and freezing cycles, in accordance with the seasons --- and the disconcerting trend of a general decrease in ice extent over the years. Inconsistant number of days in each year, mostly 365 but sometimes 366, results in a technical problem. This means that plotting cycles over the years leads to imperfect alignment. My solution was just to treat all data as if they come from a single year, 2000 which is a leap year. The measurement on February 29th for leap years is therefore not deleted; for other years, there is of course no measurement. The earliest year cycle and last year cycle are highlighted in white. A random sample from the data set: <table> <thead> <tr> <th style="text-align:left;"> Date </th> <th style="text-align:right;"> Extent (million sq km) </th> <th style="text-align:right;"> year </th> <th style="text-align:left;"> month_day </th> <th style="text-align:left;"> month_day_plus </th> <th style="text-align:right;"> proportion_ocean_covered_in_ice </th> <th style="text-align:right;"> mean_for_day </th> <th style="text-align:right;"> diff_from_mean_day </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 2012-01-03 </td> <td style="text-align:right;"> 13.379 </td> <td style="text-align:right;"> 2012 </td> <td style="text-align:left;"> 01-03 </td> <td style="text-align:left;"> 2000-01-03 </td> <td style="text-align:right;"> 0.0371639 </td> <td style="text-align:right;"> 13.664879 </td> <td style="text-align:right;"> -0.2858788 </td> </tr> <tr> <td style="text-align:left;"> 1983-08-05 </td> <td style="text-align:right;"> 8.935 </td> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> 08-05 </td> <td style="text-align:left;"> 2000-08-05 </td> <td style="text-align:right;"> 0.0248194 </td> <td style="text-align:right;"> 7.452294 </td> <td style="text-align:right;"> 1.4827059 </td> </tr> <tr> <td style="text-align:left;"> 1983-03-30 </td> <td style="text-align:right;"> 15.849 </td> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> 03-30 </td> <td style="text-align:left;"> 2000-03-30 </td> <td style="text-align:right;"> 0.0440250 </td> <td style="text-align:right;"> 15.091059 </td> <td style="text-align:right;"> 0.7579412 </td> </tr> <tr> <td style="text-align:left;"> 1991-04-28 </td> <td style="text-align:right;"> 14.249 </td> <td style="text-align:right;"> 1991 </td> <td style="text-align:left;"> 04-28 </td> <td style="text-align:left;"> 2000-04-28 </td> <td style="text-align:right;"> 0.0395806 </td> <td style="text-align:right;"> 14.084571 </td> <td style="text-align:right;"> 0.1644286 </td> </tr> <tr> <td style="text-align:left;"> 2005-05-10 </td> <td style="text-align:right;"> 13.227 </td> <td style="text-align:right;"> 2005 </td> <td style="text-align:left;"> 05-10 </td> <td style="text-align:left;"> 2000-05-10 </td> <td style="text-align:right;"> 0.0367417 </td> <td style="text-align:right;"> 13.432771 </td> <td style="text-align:right;"> -0.2057714 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(df) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + * aes(x = as.numeric(month_day_plus)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + * aes(y = `Extent (million sq km)`) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + * aes(group = year) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + * geom_line() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + * aes(col = year) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + * scale_x_continuous( * breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), * labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), * expand = c(0, 0)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + * scale_y_continuous(expand = c(0, 0), * limits = c(0, 20)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + * scale_color_continuous(guide = guide_colourbar(reverse = TRUE), * breaks = seq(2010, 1980, -10)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + * geom_line(data = df %>% filter(year == 2016 | year == 1982), * mapping = aes(lty = factor(year)), * col = "white") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + * scale_linetype_manual(name = "", values = c("dashed", "solid") ) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + * annotate(geom = "text", x = 11210, y = 15, * label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), * col = "white", * size = 7) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_22-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_23-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + * labs(y = "extent (million sq km)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_24-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + * labs(col = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_25-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + * labs(lty = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_26-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + * labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_27-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + * labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_28-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + * theme_dark(base_size = 12) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_29-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + * theme(legend.background = element_blank()) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_30-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + * theme(legend.position = c(0.1, .35)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_31-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + * theme(legend.text = element_text(colour = "white", size = 15)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_32-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + * theme(plot.background = element_rect(fill = "grey30")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_33-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + theme(plot.background = element_rect(fill = "grey30")) + * theme(plot.title = element_text(colour = "lightgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_34-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + theme(plot.background = element_rect(fill = "grey30")) + theme(plot.title = element_text(colour = "lightgrey")) + * theme(plot.subtitle = element_text(colour = "lightgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_35-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + theme(plot.background = element_rect(fill = "grey30")) + theme(plot.title = element_text(colour = "lightgrey")) + theme(plot.subtitle = element_text(colour = "lightgrey")) + * theme(axis.title = element_text(colour = "lightgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_36-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + theme(plot.background = element_rect(fill = "grey30")) + theme(plot.title = element_text(colour = "lightgrey")) + theme(plot.subtitle = element_text(colour = "lightgrey")) + theme(axis.title = element_text(colour = "lightgrey")) + * theme(axis.line = element_line(colour = "lightgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_37-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + theme(plot.background = element_rect(fill = "grey30")) + theme(plot.title = element_text(colour = "lightgrey")) + theme(plot.subtitle = element_text(colour = "lightgrey")) + theme(axis.title = element_text(colour = "lightgrey")) + theme(axis.line = element_line(colour = "lightgrey")) + * theme(axis.text = element_text(colour = "lightgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_38-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = as.numeric(month_day_plus)) + aes(y = `Extent (million sq km)`) + aes(group = year) + geom_line() + aes(col = year) + scale_x_continuous( breaks = as.numeric(lubridate::ymd(c( "2000-01-01", "2000-04-01", "2000-07-01", "2000-10-01", "2001-01-01"))), labels = c("Jan-01", "Apr-01", "Jul-01", "Oct-01", "Jan-01"), expand = c(0, 0)) + scale_y_continuous(expand = c(0, 0), limits = c(0, 20)) + scale_color_continuous(guide = guide_colourbar(reverse = TRUE), breaks = seq(2010, 1980, -10)) + geom_line(data = df %>% filter(year == 2016 | year == 1982), mapping = aes(lty = factor(year)), col = "white") + scale_linetype_manual(name = "", values = c("dashed", "solid") ) + annotate(geom = "text", x = 11210, y = 15, label = str_wrap("For this period, 1982 had the highest calendar-year average extent of Arctic sea ice while 2016 had the lowest", 30), col = "white", size = 7) + labs(x = "") + labs(y = "extent (million sq km)") + labs(col = "") + labs(lty = "") + labs(title = "Freezing cycles: Arctic sea ice extent, 1979-2017") + labs(subtitle = "Data Source: National Snow & Ice Data Center | Vis: Gina Reynolds for #MakeoverMonday") + theme_dark(base_size = 12) + theme(legend.background = element_blank()) + theme(legend.position = c(0.1, .35)) + theme(legend.text = element_text(colour = "white", size = 15)) + theme(plot.background = element_rect(fill = "grey30")) + theme(plot.title = element_text(colour = "lightgrey")) + theme(plot.subtitle = element_text(colour = "lightgrey")) + theme(axis.title = element_text(colour = "lightgrey")) + theme(axis.line = element_line(colour = "lightgrey")) + theme(axis.text = element_text(colour = "lightgrey")) + * theme(axis.ticks = element_line(colour = "lightgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_ice_39-1.png" width="80%" /> ]] --- name: collegemajors01 # College Majors ```r dir <- "raw_data" file <- paste0(dir, "/", "recent_grads.csv") url <- "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2018/2018-10-16/recent-grads.csv" # create raw_data folder if (!dir.exists(dir)) { dir.create(dir) } # download data from internet and save if (!file.exists(file)) { download.file(url = url, destfile = file) } # read in downloaded data df <- readr::read_csv(file) ``` ```r college_majors <- df %>% group_by(Major_category) %>% mutate(mean_share_women = mean(ShareWomen)) %>% mutate(share_non_college_jobs = Non_college_jobs/Total) summarized <- college_majors %>% group_by(Major_category) %>% summarise(mean_share_women = mean(ShareWomen), mean_unemployment_rate = mean(Unemployment_rate), mean_share_non_college = mean(share_non_college_jobs)) %>% arrange(mean_unemployment_rate) my_line <- c(100,1000,10000, 100000, 400000) library(ggrepel) ``` --- class: split-40 count: false .column[.content[ ```r *ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + * aes(Total) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + * aes(y = Unemployed) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + * aes(label = paste0(Major, "\n$", Median, " annual" )) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + * aes(col = Median/1000) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + * scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + * scale_y_log10() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + * coord_equal() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + * annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + * annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + * annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + * annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + * annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + * annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + * annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + * annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + * annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + * labs(x = "Number of new graduates in field (thousands)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + * labs(y = "Number Unemployed") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_19-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + * labs(title = "Are niche fields less prone to unemployment?") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_20-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + * labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_21-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + * geom_point(alpha = .8) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_22-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + geom_point(alpha = .8) + * scale_colour_viridis_c(option = "D", alpha = .8) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_23-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + geom_point(alpha = .8) + scale_colour_viridis_c(option = "D", alpha = .8) + * facet_wrap(~ Major_category, nrow = 3) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_24-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + geom_point(alpha = .8) + scale_colour_viridis_c(option = "D", alpha = .8) + facet_wrap(~ Major_category, nrow = 3) + * theme_bw(base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_25-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + geom_point(alpha = .8) + scale_colour_viridis_c(option = "D", alpha = .8) + facet_wrap(~ Major_category, nrow = 3) + theme_bw(base_family = "Times") + * labs(col = "Median Earnings\n(thousands $ per year)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_26-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + geom_point(alpha = .8) + scale_colour_viridis_c(option = "D", alpha = .8) + facet_wrap(~ Major_category, nrow = 3) + theme_bw(base_family = "Times") + labs(col = "Median Earnings\n(thousands $ per year)") + * ggpmisc::stat_dens2d_filter(geom = "text_repel", keep.fraction = 0.50, size = 1, alpha = 1) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_27-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors %>% mutate(Unemployed = ifelse(Unemployed == 0, 1, Unemployed))) + aes(Total) + aes(y = Unemployed) + aes(label = paste0(Major, "\n$", Median, " annual" )) + aes(col = Median/1000) + scale_x_log10(breaks = c(1000,10000, 100000), labels = c(1000,10000, 100000)/1000) + scale_y_log10() + coord_equal() + annotate(geom = "line", x = my_line, y = my_line/10, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/20, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/40, lty = "dotted") + annotate(geom = "line", x = my_line, y = my_line/80, lty = "dotted") + annotate(geom = "text",x = 100,y = 100/80,label = paste0(100/80, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/10,label = paste0(100/10, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/20,label = paste0(100/20, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 100,y = 100/40,label = paste0(100/40, "%"),hjust = 1, size = 2) + annotate(geom = "text",x = 1000,y = 7, label = "Percent Unemployment", angle = 45, size = 2) + labs(x = "Number of new graduates in field (thousands)") + labs(y = "Number Unemployed") + labs(title = "Are niche fields less prone to unemployment?") + labs(subtitle = "Data Source: PUMS Survey of New Graduates via 538 and @TidyTuesday\nViz: @EvaMaeRey") + geom_point(alpha = .8) + scale_colour_viridis_c(option = "D", alpha = .8) + facet_wrap(~ Major_category, nrow = 3) + theme_bw(base_family = "Times") + labs(col = "Median Earnings\n(thousands $ per year)") + ggpmisc::stat_dens2d_filter(geom = "text_repel", keep.fraction = 0.50, size = 1, alpha = 1) + * expand_limits(x = c(40,0)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_01_28-1.png" width="80%" /> ]] --- name: collegemajors02 class: split-40 count: false .column[.content[ ```r *ggplot(data = college_majors ) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + * aes(x = share_non_college_jobs) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + * aes(y = Unemployment_rate) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + * aes(label = Major) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + * aes(col = Median/1000) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + * facet_wrap(~ factor(Major_category, * summarized$Major_category)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + * geom_point(alpha = .7) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + * geom_vline(data = summarized, * mapping = aes(xintercept = mean_share_non_college), * lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + * geom_hline(data = summarized, * mapping = aes(yintercept = mean_unemployment_rate), * lty = "dotted") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + * theme_light() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + * scale_colour_viridis_c(option = "viridis") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + scale_colour_viridis_c(option = "viridis") + * labs(y = "unemployment rate") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + scale_colour_viridis_c(option = "viridis") + labs(y = "unemployment rate") + * labs(x = "share working jobs requiring no college") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + scale_colour_viridis_c(option = "viridis") + labs(y = "unemployment rate") + labs(x = "share working jobs requiring no college") + * labs(size = "Total\nestimated\n(thousands)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_19-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + scale_colour_viridis_c(option = "viridis") + labs(y = "unemployment rate") + labs(x = "share working jobs requiring no college") + labs(size = "Total\nestimated\n(thousands)") + * labs(col = "Median\nsalary\n(thousands US$)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_20-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + scale_colour_viridis_c(option = "viridis") + labs(y = "unemployment rate") + labs(x = "share working jobs requiring no college") + labs(size = "Total\nestimated\n(thousands)") + labs(col = "Median\nsalary\n(thousands US$)") + * labs(title = "Recent graduates: Unemployment and Share working jobs not requiring college degree") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_21-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = college_majors ) + aes(x = share_non_college_jobs) + aes(y = Unemployment_rate) + aes(label = Major) + aes(col = Median/1000) + facet_wrap(~ factor(Major_category, summarized$Major_category)) + geom_point(alpha = .7) + geom_vline(data = summarized, mapping = aes(xintercept = mean_share_non_college), lty = "dotted") + geom_hline(data = summarized, mapping = aes(yintercept = mean_unemployment_rate), lty = "dotted") + theme_light() + scale_colour_viridis_c(option = "viridis") + labs(y = "unemployment rate") + labs(x = "share working jobs requiring no college") + labs(size = "Total\nestimated\n(thousands)") + labs(col = "Median\nsalary\n(thousands US$)") + labs(title = "Recent graduates: Unemployment and Share working jobs not requiring college degree") + * labs(subtitle = "@EvaMaeRey for #TidyTuesday|Data Source: American Community Survey 2010-2012") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_recent_grads_02_22-1.png" width="80%" /> ]] --- name: flippingseats # Flipping seats --- class: split-40 count: false .column[.content[ ```r *ggplot(df) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + * aes(x = factor(year), y = percent) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + * facet_wrap(~ forcats::fct_inorder(category), * nrow = 1) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + * geom_col(aes(y = 100), fill = "white", * width = .6, alpha = .1, col = "grey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + * geom_col(width = .6, alpha = .5) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + * aes(fill = category == "White men") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + * ylim(c(0,100)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + * theme_bw() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + * labs(y = "Demographic's percentage \n of the seat flipping") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + labs(y = "Demographic's percentage \n of the seat flipping") + * aes(group = category) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + labs(y = "Demographic's percentage \n of the seat flipping") + aes(group = category) + * geom_line(col = "grey", lty = "dashed", * mapping = aes(x = c(1.3, 1.3, 1.3, 1.3, 1.7, 1.7, 1.7, 1.7))) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + labs(y = "Demographic's percentage \n of the seat flipping") + aes(group = category) + geom_line(col = "grey", lty = "dashed", mapping = aes(x = c(1.3, 1.3, 1.3, 1.3, 1.7, 1.7, 1.7, 1.7))) + * scale_fill_manual(values = c("blue", "darkgrey"), guide = FALSE) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + labs(y = "Demographic's percentage \n of the seat flipping") + aes(group = category) + geom_line(col = "grey", lty = "dashed", mapping = aes(x = c(1.3, 1.3, 1.3, 1.3, 1.7, 1.7, 1.7, 1.7))) + scale_fill_manual(values = c("blue", "darkgrey"), guide = FALSE) + * labs(title = "Who's the face of the 'Blue Wave'?") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + labs(y = "Demographic's percentage \n of the seat flipping") + aes(group = category) + geom_line(col = "grey", lty = "dashed", mapping = aes(x = c(1.3, 1.3, 1.3, 1.3, 1.7, 1.7, 1.7, 1.7))) + scale_fill_manual(values = c("blue", "darkgrey"), guide = FALSE) + labs(title = "Who's the face of the 'Blue Wave'?") + * labs(subtitle = "Data: https://twitter.com/williamjordann/status/1063482594938028032 \n --- seats were flipped to democratic in 2006, and --- seats in 2018") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = factor(year), y = percent) + facet_wrap(~ forcats::fct_inorder(category), nrow = 1) + geom_col(aes(y = 100), fill = "white", width = .6, alpha = .1, col = "grey") + geom_col(width = .6, alpha = .5) + aes(fill = category == "White men") + ylim(c(0,100)) + theme_bw() + labs(x = "") + labs(y = "Demographic's percentage \n of the seat flipping") + aes(group = category) + geom_line(col = "grey", lty = "dashed", mapping = aes(x = c(1.3, 1.3, 1.3, 1.3, 1.7, 1.7, 1.7, 1.7))) + scale_fill_manual(values = c("blue", "darkgrey"), guide = FALSE) + labs(title = "Who's the face of the 'Blue Wave'?") + labs(subtitle = "Data: https://twitter.com/williamjordann/status/1063482594938028032 \n --- seats were flipped to democratic in 2006, and --- seats in 2018") + * labs(caption = "Chart by Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_flipping_seats_19-1.png" width="80%" /> ]] --- name: ratings # Highlighting among ratings Fine tuning a plot. Compare the following plot to other possible ways of displaying similar data: https://twitter.com/FILWD/status/1060212703636217856 --- class: split-40 count: false .column[.content[ ```r *ggplot(df) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + * aes(x = rank) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + * aes(y = outcome) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + * geom_point(size = 2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + * facet_grid(. ~ cat) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + * aes(col = company) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + * aes(shape = company) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + * aes(size = company) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + * labs(x = "Rank for among companies for feature") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + * scale_color_manual(name = "", * values = c("steelblue", "darkgrey", * "darkgrey", "darkgrey", * "darkgrey")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + scale_color_manual(name = "", values = c("steelblue", "darkgrey", "darkgrey", "darkgrey", "darkgrey")) + * scale_shape_discrete(name = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + scale_color_manual(name = "", values = c("steelblue", "darkgrey", "darkgrey", "darkgrey", "darkgrey")) + scale_shape_discrete(name = "") + * theme_bw(base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + scale_color_manual(name = "", values = c("steelblue", "darkgrey", "darkgrey", "darkgrey", "darkgrey")) + scale_shape_discrete(name = "") + theme_bw(base_family = "Times") + * labs(title = "Average Score and Ranks across features exercise w/ R & ggplot2") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + scale_color_manual(name = "", values = c("steelblue", "darkgrey", "darkgrey", "darkgrey", "darkgrey")) + scale_shape_discrete(name = "") + theme_bw(base_family = "Times") + labs(title = "Average Score and Ranks across features exercise w/ R & ggplot2") + * labs(subtitle = "Data Source: Randomly generated toy data in R | Viz: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + scale_color_manual(name = "", values = c("steelblue", "darkgrey", "darkgrey", "darkgrey", "darkgrey")) + scale_shape_discrete(name = "") + theme_bw(base_family = "Times") + labs(title = "Average Score and Ranks across features exercise w/ R & ggplot2") + labs(subtitle = "Data Source: Randomly generated toy data in R | Viz: Gina Reynolds") + * labs(y = "Average Score") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_18-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df) + aes(x = rank) + aes(y = outcome) + geom_point(size = 2) + facet_grid(. ~ cat) + aes(col = company) + aes(shape = company) + aes(size = company) + labs(x = "Rank for among companies for feature") + scale_color_manual(name = "", values = c("steelblue", "darkgrey", "darkgrey", "darkgrey", "darkgrey")) + scale_shape_discrete(name = "") + theme_bw(base_family = "Times") + labs(title = "Average Score and Ranks across features exercise w/ R & ggplot2") + labs(subtitle = "Data Source: Randomly generated toy data in R | Viz: Gina Reynolds") + labs(y = "Average Score") + * scale_x_continuous(breaks = 1:5, labels = 1:5, * limits = c(.5, 5.5)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_company_ranks_20-1.png" width="80%" /> ]] --- name: incarcerationbysex # Incarceration This visualization is a sobering one --- showing incarceration rates across different demographics over time. The data comes via #TidyTuesday via the Vera Institute of Justice. My strategy is pretty simple - to show changes in rates over time for different groups using facet grid. A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> year </th> <th style="text-align:left;"> urbanicity </th> <th style="text-align:left;"> pop_category </th> <th style="text-align:right;"> rate_per_100000 </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> rural </td> <td style="text-align:left;"> Female </td> <td style="text-align:right;"> 22.79699 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> rural </td> <td style="text-align:left;"> Male </td> <td style="text-align:right;"> 573.79747 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> small/mid </td> <td style="text-align:left;"> Female </td> <td style="text-align:right;"> 26.55939 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> small/mid </td> <td style="text-align:left;"> Male </td> <td style="text-align:right;"> 549.74687 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> suburban </td> <td style="text-align:left;"> Female </td> <td style="text-align:right;"> 15.21089 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r * ggplot(data = data) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + * aes(x = year, y = rate_per_100000) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = year, y = rate_per_100000) + * geom_line() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = year, y = rate_per_100000) + geom_line() + * facet_grid(urbanicity ~ pop_category) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + * theme_minimal(base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + theme_minimal(base_family = "Times") + * labs(x = "", y = "Incarcerated per 100000") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + theme_minimal(base_family = "Times") + labs(x = "", y = "Incarcerated per 100000") + * labs(subtitle = "Data source: Vera Institute of Justice") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = data) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + theme_minimal(base_family = "Times") + labs(x = "", y = "Incarcerated per 100000") + labs(subtitle = "Data source: Vera Institute of Justice") + * labs(title = "Incarceration rates by sex and urbanicity in the US, 1983-2015") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_01_8-1.png" width="80%" /> ]] --- name: incarcerationbygender A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> year </th> <th style="text-align:left;"> urbanicity </th> <th style="text-align:left;"> pop_category </th> <th style="text-align:right;"> rate_per_100000 </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> rural </td> <td style="text-align:left;"> Black </td> <td style="text-align:right;"> 1116.8762 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> rural </td> <td style="text-align:left;"> White </td> <td style="text-align:right;"> 154.6412 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> small/mid </td> <td style="text-align:left;"> Black </td> <td style="text-align:right;"> 1137.5779 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> small/mid </td> <td style="text-align:left;"> White </td> <td style="text-align:right;"> 149.7800 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:left;"> suburban </td> <td style="text-align:left;"> Black </td> <td style="text-align:right;"> 880.4485 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = dat) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + * aes(x = year, y = rate_per_100000) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + aes(x = year, y = rate_per_100000) + * geom_line() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + aes(x = year, y = rate_per_100000) + geom_line() + * facet_grid(urbanicity ~ pop_category) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + * theme_minimal(base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + theme_minimal(base_family = "Times") + * labs(x = "", y = "Incarcerated per 100000") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + theme_minimal(base_family = "Times") + labs(x = "", y = "Incarcerated per 100000") + * labs(subtitle = "Data source: Vera Institute of Justice") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = dat) + aes(x = year, y = rate_per_100000) + geom_line() + facet_grid(urbanicity ~ pop_category) + theme_minimal(base_family = "Times") + labs(x = "", y = "Incarcerated per 100000") + labs(subtitle = "Data source: Vera Institute of Justice") + * labs(title = "Incarceration rates by race/ethnicity and urbanicity in the US, 1983-2015") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_incarceration_02_8-1.png" width="80%" /> ]] --- name: milkindustry # Milk Industry What's a milk cow worth? This data comes via the #TidyTuesday project. I constructed a waterfall plot to track the average price of milk cows, calculating percent changes year on year. A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> year </th> <th style="text-align:right;"> avg_milk_cow_number </th> <th style="text-align:right;"> milk_per_cow </th> <th style="text-align:right;"> milk_production_lbs </th> <th style="text-align:right;"> avg_price_milk </th> <th style="text-align:right;"> dairy_ration </th> <th style="text-align:right;"> milk_feed_price_ratio </th> <th style="text-align:right;"> milk_cow_cost_per_animal </th> <th style="text-align:right;"> milk_volume_to_buy_cow_in_lbs </th> <th style="text-align:right;"> alfalfa_hay_price </th> <th style="text-align:right;"> slaughter_cow_price </th> <th style="text-align:right;"> milk_cow_cost_per_animal_lag </th> <th style="text-align:right;"> between_cost </th> <th style="text-align:right;"> percent_change </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 1980 </td> <td style="text-align:right;"> 10799000 </td> <td style="text-align:right;"> 11891 </td> <td style="text-align:right;"> 1.28406e+11 </td> <td style="text-align:right;"> 0.130 </td> <td style="text-align:right;"> 0.0483736 </td> <td style="text-align:right;"> 2.717149 </td> <td style="text-align:right;"> 1190 </td> <td style="text-align:right;"> 9153.846 </td> <td style="text-align:right;"> 72.00000 </td> <td style="text-align:right;"> 0.4573 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> NA </td> </tr> <tr> <td style="text-align:right;"> 1981 </td> <td style="text-align:right;"> 10898000 </td> <td style="text-align:right;"> 12183 </td> <td style="text-align:right;"> 1.32770e+11 </td> <td style="text-align:right;"> 0.138 </td> <td style="text-align:right;"> 0.0503524 </td> <td style="text-align:right;"> 2.759031 </td> <td style="text-align:right;"> 1200 </td> <td style="text-align:right;"> 8695.652 </td> <td style="text-align:right;"> 70.90000 </td> <td style="text-align:right;"> 0.4193 </td> <td style="text-align:right;"> 1190 </td> <td style="text-align:right;"> 1195.0 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:right;"> 1982 </td> <td style="text-align:right;"> 11011000 </td> <td style="text-align:right;"> 12306 </td> <td style="text-align:right;"> 1.35505e+11 </td> <td style="text-align:right;"> 0.136 </td> <td style="text-align:right;"> 0.0442210 </td> <td style="text-align:right;"> 3.088127 </td> <td style="text-align:right;"> 1110 </td> <td style="text-align:right;"> 8161.765 </td> <td style="text-align:right;"> 72.73333 </td> <td style="text-align:right;"> 0.3996 </td> <td style="text-align:right;"> 1200 </td> <td style="text-align:right;"> 1155.0 </td> <td style="text-align:right;"> -8 </td> </tr> <tr> <td style="text-align:right;"> 1983 </td> <td style="text-align:right;"> 11059000 </td> <td style="text-align:right;"> 12622 </td> <td style="text-align:right;"> 1.39588e+11 </td> <td style="text-align:right;"> 0.136 </td> <td style="text-align:right;"> 0.0523503 </td> <td style="text-align:right;"> 2.609620 </td> <td style="text-align:right;"> 1030 </td> <td style="text-align:right;"> 7573.529 </td> <td style="text-align:right;"> 78.70000 </td> <td style="text-align:right;"> 0.3935 </td> <td style="text-align:right;"> 1110 </td> <td style="text-align:right;"> 1070.0 </td> <td style="text-align:right;"> -7 </td> </tr> <tr> <td style="text-align:right;"> 1984 </td> <td style="text-align:right;"> 10793000 </td> <td style="text-align:right;"> 12541 </td> <td style="text-align:right;"> 1.35351e+11 </td> <td style="text-align:right;"> 0.135 </td> <td style="text-align:right;"> 0.0533879 </td> <td style="text-align:right;"> 2.540000 </td> <td style="text-align:right;"> 895 </td> <td style="text-align:right;"> 6629.630 </td> <td style="text-align:right;"> 79.48333 </td> <td style="text-align:right;"> 0.3981 </td> <td style="text-align:right;"> 1030 </td> <td style="text-align:right;"> 962.5 </td> <td style="text-align:right;"> -13 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r * ggplot(df_changes) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + * aes(xmin = year - .3, * xmax = year + .3) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + * aes(ymin = milk_cow_cost_per_animal_lag, * ymax = milk_cow_cost_per_animal) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + * geom_rect(fill = "blue", alpha = .3) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + * geom_col(data = df %>% filter(year == 2004), * mapping = aes(x = year, y = milk_cow_cost_per_animal), * fill = "grey", alpha = .5) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + * labs(fill = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + * labs(y = "Cost (US$)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_12-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + * labs(title = "Cost of milk cows in the United States") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_13-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + * labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + * scale_y_continuous(limits = c(0, 2004)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_15-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + * scale_x_continuous(breaks = seq(2004, 2014, by = 2), * limits = c(2003.5, 2014.5)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_17-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + * aes(x = year - .5, * xend = year + 1.5) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_19-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + * aes(y = milk_cow_cost_per_animal, * yend = milk_cow_cost_per_animal) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_21-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + * geom_segment(data = df %>% filter(year >= 2004 & year < 2014), * linetype = "dashed", col = "gray39") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_23-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + * geom_segment(data = df %>% filter(year == 2014), * linetype = "dashed", col = "gray39", * mapping = aes(x = year - .5, xend = year + .5)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_26-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + * scale_fill_viridis_d() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_27-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + scale_fill_viridis_d() + * theme_bw(base_family = "Times") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_28-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + scale_fill_viridis_d() + theme_bw(base_family = "Times") + * aes(label = paste0(percent_change, "%")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_29-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + scale_fill_viridis_d() + theme_bw(base_family = "Times") + aes(label = paste0(percent_change, "%")) + * geom_text(mapping = aes(y = milk_cow_cost_per_animal, * x = year, * col = percent_change > 0), * size = 3, nudge_y = 90 * ((df_changes$percent_change > 0) - .5), * show.legend = F) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_34-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + scale_fill_viridis_d() + theme_bw(base_family = "Times") + aes(label = paste0(percent_change, "%")) + geom_text(mapping = aes(y = milk_cow_cost_per_animal, x = year, col = percent_change > 0), size = 3, nudge_y = 90 * ((df_changes$percent_change > 0) - .5), show.legend = F) + * scale_color_manual(values = c("tomato4", "gray39")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_35-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + scale_fill_viridis_d() + theme_bw(base_family = "Times") + aes(label = paste0(percent_change, "%")) + geom_text(mapping = aes(y = milk_cow_cost_per_animal, x = year, col = percent_change > 0), size = 3, nudge_y = 90 * ((df_changes$percent_change > 0) - .5), show.legend = F) + scale_color_manual(values = c("tomato4", "gray39")) + * labs(x = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_36-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(df_changes) + aes(xmin = year - .3, xmax = year + .3) + aes(ymin = milk_cow_cost_per_animal_lag, ymax = milk_cow_cost_per_animal) + geom_rect(fill = "blue", alpha = .3) + geom_col(data = df %>% filter(year == 2004), mapping = aes(x = year, y = milk_cow_cost_per_animal), fill = "grey", alpha = .5) + labs(x = "") + labs(fill = "") + labs(y = "Cost (US$)") + labs(title = "Cost of milk cows in the United States") + labs(subtitle = "Per animal cost, 2004-2014 | Viz: Gina Reynolds") + scale_y_continuous(limits = c(0, 2004)) + scale_x_continuous(breaks = seq(2004, 2014, by = 2), limits = c(2003.5, 2014.5)) + aes(x = year - .5, xend = year + 1.5) + aes(y = milk_cow_cost_per_animal, yend = milk_cow_cost_per_animal) + geom_segment(data = df %>% filter(year >= 2004 & year < 2014), linetype = "dashed", col = "gray39") + geom_segment(data = df %>% filter(year == 2014), linetype = "dashed", col = "gray39", mapping = aes(x = year - .5, xend = year + .5)) + scale_fill_viridis_d() + theme_bw(base_family = "Times") + aes(label = paste0(percent_change, "%")) + geom_text(mapping = aes(y = milk_cow_cost_per_animal, x = year, col = percent_change > 0), size = 3, nudge_y = 90 * ((df_changes$percent_change > 0) - .5), show.legend = F) + scale_color_manual(values = c("tomato4", "gray39")) + labs(x = "") + * labs(y = "Price ($US)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_milk_37-1.png" width="80%" /> ]] --- name: windturbinelocations01 # Wind Turbine Locations This data on wind turbine locations comes via the #TidyTuesday project. I map the positions of the turbines in the US. A random sample from the data set: <table> <thead> <tr> <th style="text-align:right;"> case_id </th> <th style="text-align:left;"> faa_ors </th> <th style="text-align:left;"> faa_asn </th> <th style="text-align:right;"> usgs_pr_id </th> <th style="text-align:left;"> t_state </th> <th style="text-align:left;"> t_county </th> <th style="text-align:left;"> t_fips </th> <th style="text-align:left;"> p_name </th> <th style="text-align:right;"> p_year </th> <th style="text-align:right;"> p_tnum </th> <th style="text-align:right;"> p_cap </th> <th style="text-align:left;"> t_manu </th> <th style="text-align:left;"> t_model </th> <th style="text-align:right;"> t_cap </th> <th style="text-align:right;"> t_hh </th> <th style="text-align:right;"> t_rd </th> <th style="text-align:right;"> t_rsa </th> <th style="text-align:right;"> t_ttlh </th> <th style="text-align:right;"> t_conf_atr </th> <th style="text-align:right;"> t_conf_loc </th> <th style="text-align:left;"> t_img_date </th> <th style="text-align:left;"> t_img_srce </th> <th style="text-align:right;"> xlong </th> <th style="text-align:right;"> ylat </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 3073429 </td> <td style="text-align:left;"> missing </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 4960 </td> <td style="text-align:left;"> CA </td> <td style="text-align:left;"> Kern County </td> <td style="text-align:left;"> 06029 </td> <td style="text-align:left;"> 251 Wind </td> <td style="text-align:right;"> 1987 </td> <td style="text-align:right;"> 194 </td> <td style="text-align:right;"> 18.43 </td> <td style="text-align:left;"> Vestas </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 1/1/2012 </td> <td style="text-align:left;"> NAIP </td> <td style="text-align:right;"> -118.3607 </td> <td style="text-align:right;"> 35.08378 </td> </tr> <tr> <td style="text-align:right;"> 3071522 </td> <td style="text-align:left;"> missing </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 4997 </td> <td style="text-align:left;"> CA </td> <td style="text-align:left;"> Kern County </td> <td style="text-align:left;"> 06029 </td> <td style="text-align:left;"> 251 Wind </td> <td style="text-align:right;"> 1987 </td> <td style="text-align:right;"> 194 </td> <td style="text-align:right;"> 18.43 </td> <td style="text-align:left;"> Vestas </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 1/1/2012 </td> <td style="text-align:left;"> NAIP </td> <td style="text-align:right;"> -118.3612 </td> <td style="text-align:right;"> 35.08151 </td> </tr> <tr> <td style="text-align:right;"> 3073425 </td> <td style="text-align:left;"> missing </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 4957 </td> <td style="text-align:left;"> CA </td> <td style="text-align:left;"> Kern County </td> <td style="text-align:left;"> 06029 </td> <td style="text-align:left;"> 251 Wind </td> <td style="text-align:right;"> 1987 </td> <td style="text-align:right;"> 194 </td> <td style="text-align:right;"> 18.43 </td> <td style="text-align:left;"> Vestas </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 1/1/2012 </td> <td style="text-align:left;"> NAIP </td> <td style="text-align:right;"> -118.3604 </td> <td style="text-align:right;"> 35.08471 </td> </tr> <tr> <td style="text-align:right;"> 3071569 </td> <td style="text-align:left;"> missing </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 5023 </td> <td style="text-align:left;"> CA </td> <td style="text-align:left;"> Kern County </td> <td style="text-align:left;"> 06029 </td> <td style="text-align:left;"> 251 Wind </td> <td style="text-align:right;"> 1987 </td> <td style="text-align:right;"> 194 </td> <td style="text-align:right;"> 18.43 </td> <td style="text-align:left;"> Vestas </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 7/31/2016 </td> <td style="text-align:left;"> Digital Globe </td> <td style="text-align:right;"> -118.3640 </td> <td style="text-align:right;"> 35.07942 </td> </tr> <tr> <td style="text-align:right;"> 3005252 </td> <td style="text-align:left;"> missing </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 5768 </td> <td style="text-align:left;"> CA </td> <td style="text-align:left;"> Kern County </td> <td style="text-align:left;"> 06029 </td> <td style="text-align:left;"> 251 Wind </td> <td style="text-align:right;"> 1987 </td> <td style="text-align:right;"> 194 </td> <td style="text-align:right;"> 18.43 </td> <td style="text-align:left;"> Vestas </td> <td style="text-align:left;"> missing </td> <td style="text-align:right;"> 95 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> -9999 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:left;"> 11/23/2017 </td> <td style="text-align:left;"> Digital Globe </td> <td style="text-align:right;"> -118.3543 </td> <td style="text-align:right;"> 35.08559 </td> </tr> </tbody> </table> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = usa) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + * aes(x = long, y = lat, group = group) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + * geom_polygon(fill = "blue", alpha = .4) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + * theme_classic() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + theme_classic() + * coord_map(projection = "mercator") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + theme_classic() + coord_map(projection = "mercator") + * geom_point(data = us_wind %>% filter(ylat < 50 & ylat > 25), * mapping = aes(x = xlong, y = ylat, group = NULL), * size = .5, col = "orange", alpha = .6) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + theme_classic() + coord_map(projection = "mercator") + geom_point(data = us_wind %>% filter(ylat < 50 & ylat > 25), mapping = aes(x = xlong, y = ylat, group = NULL), size = .5, col = "orange", alpha = .6) + * theme_void() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + theme_classic() + coord_map(projection = "mercator") + geom_point(data = us_wind %>% filter(ylat < 50 & ylat > 25), mapping = aes(x = xlong, y = ylat, group = NULL), size = .5, col = "orange", alpha = .6) + theme_void() + * labs(title = "Wind turbines in the continental US") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_10-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + theme_classic() + coord_map(projection = "mercator") + geom_point(data = us_wind %>% filter(ylat < 50 & ylat > 25), mapping = aes(x = xlong, y = ylat, group = NULL), size = .5, col = "orange", alpha = .6) + theme_void() + labs(title = "Wind turbines in the continental US") + * labs(caption = "Tidy Tuesday exercise") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = usa) + aes(x = long, y = lat, group = group) + geom_polygon(fill = "blue", alpha = .4) + theme_classic() + coord_map(projection = "mercator") + geom_point(data = us_wind %>% filter(ylat < 50 & ylat > 25), mapping = aes(x = xlong, y = ylat, group = NULL), size = .5, col = "orange", alpha = .6) + theme_void() + labs(title = "Wind turbines in the continental US") + labs(caption = "Tidy Tuesday exercise") + * labs(subtitle = "Data Source: | Visualization: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_01_12-1.png" width="80%" /> ]] --- name: windturbinelocations02 class: split-40 count: false .column[.content[ ```r * ggplot(data) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + * aes(x = xlong, y = ylat) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + * borders("state") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + * geom_point(col = "steelblue", alpha = .2) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "steelblue", alpha = .2) + * theme_void() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "steelblue", alpha = .2) + theme_void() + * coord_map(projection = "mercator") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "steelblue", alpha = .2) + theme_void() + coord_map(projection = "mercator") + * geom_density_2d(col = "darkgrey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "steelblue", alpha = .2) + theme_void() + coord_map(projection = "mercator") + geom_density_2d(col = "darkgrey") + * labs(title = "Wind turbines in the continental US") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "steelblue", alpha = .2) + theme_void() + coord_map(projection = "mercator") + geom_density_2d(col = "darkgrey") + labs(title = "Wind turbines in the continental US") + * labs(caption = "Tidy Tuesday exercise") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data) + aes(x = xlong, y = ylat) + borders("state") + geom_point(col = "steelblue", alpha = .2) + theme_void() + coord_map(projection = "mercator") + geom_density_2d(col = "darkgrey") + labs(title = "Wind turbines in the continental US") + labs(caption = "Tidy Tuesday exercise") + * labs(subtitle = "Data Source: | Visualization: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_wind_02_10-1.png" width="80%" /> ]] --- name: movies # Movies --- --- class: split-40 count: false .column[.content[ ```r *ggplot(data = movies) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_1-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + * aes(x = production_budget) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_2-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + * aes(y = worldwide_gross/production_budget) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_3-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + * geom_point(alpha = .25) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_4-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + * facet_wrap(~ genre) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_5-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + * theme_bw() ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_6-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + * aes(col = lubridate::year(release_date)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_7-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + * scale_color_viridis_c(option = "B") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_8-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + * labs(col = "") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_9-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + * scale_x_log10(labels = scales::dollar_format(), * limits = c(100000, 100000000)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_11-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + * scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), * label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), * limits = c(.0001, 1000)) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_14-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + * aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), * "mil.")) ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_16-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + * ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), * geom = "text_repel", keep.fraction = 0.06, * size = 2.8, col = "darkgrey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_19-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), geom = "text_repel", keep.fraction = 0.06, size = 2.8, col = "darkgrey") + * ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross<production_budget), * geom = "text_repel", keep.fraction = 0.002, * size = 2.8, col = "darkgrey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_22-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), geom = "text_repel", keep.fraction = 0.06, size = 2.8, col = "darkgrey") + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross<production_budget), geom = "text_repel", keep.fraction = 0.002, size = 2.8, col = "darkgrey") + * geom_abline(intercept = 0, slope = 0, lty = 2, col = "darkgrey") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_23-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), geom = "text_repel", keep.fraction = 0.06, size = 2.8, col = "darkgrey") + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross<production_budget), geom = "text_repel", keep.fraction = 0.002, size = 2.8, col = "darkgrey") + geom_abline(intercept = 0, slope = 0, lty = 2, col = "darkgrey") + * labs(x = "production budget") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_24-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), geom = "text_repel", keep.fraction = 0.06, size = 2.8, col = "darkgrey") + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross<production_budget), geom = "text_repel", keep.fraction = 0.002, size = 2.8, col = "darkgrey") + geom_abline(intercept = 0, slope = 0, lty = 2, col = "darkgrey") + labs(x = "production budget") + * labs(y = "Profit ratio (worldwide gross)") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_25-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), geom = "text_repel", keep.fraction = 0.06, size = 2.8, col = "darkgrey") + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross<production_budget), geom = "text_repel", keep.fraction = 0.002, size = 2.8, col = "darkgrey") + geom_abline(intercept = 0, slope = 0, lty = 2, col = "darkgrey") + labs(x = "production budget") + labs(y = "Profit ratio (worldwide gross)") + * labs(title = "Profit ratio in a 538 movies dataset") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_26-1.png" width="80%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = movies) + aes(x = production_budget) + aes(y = worldwide_gross/production_budget) + geom_point(alpha = .25) + facet_wrap(~ genre) + theme_bw() + aes(col = lubridate::year(release_date)) + scale_color_viridis_c(option = "B") + labs(col = "") + scale_x_log10(labels = scales::dollar_format(), limits = c(100000, 100000000)) + scale_y_log10(breaks = c(.0001,.001,.01,.1,1,10,100, 1000), label = c(".0001X", ".001X", ".01X", ".1X", "1X", "10X", "100X", "1000X"), limits = c(.0001, 1000)) + aes(label = paste0(movie, "\n$", round(production_budget/1000000, 2), "mil.")) + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross>10*production_budget), geom = "text_repel", keep.fraction = 0.06, size = 2.8, col = "darkgrey") + ggpmisc::stat_dens2d_filter(data = movies %>% filter(worldwide_gross<production_budget), geom = "text_repel", keep.fraction = 0.002, size = 2.8, col = "darkgrey") + geom_abline(intercept = 0, slope = 0, lty = 2, col = "darkgrey") + labs(x = "production budget") + labs(y = "Profit ratio (worldwide gross)") + labs(title = "Profit ratio in a 538 movies dataset") + * labs(subtitle = "Data source: 538 via TidyTuesday | Vis: Gina Reynolds") ``` ]] .column[.content.center[ <img src="ggplot_flipbook_xaringan_files/figure-html/output_movies_27-1.png" width="80%" /> ]] --- <style type="text/css"> .remark-code{line-height: 1.5; font-size: 65%} </style>