class: center, middle, inverse, title-slide # Ex. 4.3: Dot Plot --- count: false .panel1-the_chunk-auto[ ```r *library(gapminder) ``` ] .panel2-the_chunk-auto[ ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) *gapminder ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 1,704 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 1952 28.8 8425333 779. 2 Afghanistan Asia 1957 30.3 9240934 821. 3 Afghanistan Asia 1962 32.0 10267083 853. 4 Afghanistan Asia 1967 34.0 11537966 836. 5 Afghanistan Asia 1972 36.1 13079460 740. 6 Afghanistan Asia 1977 38.4 14880372 786. 7 Afghanistan Asia 1982 39.9 12881816 978. 8 Afghanistan Asia 1987 40.8 13867957 852. 9 Afghanistan Asia 1992 41.7 16317921 649. 10 Afghanistan Asia 1997 41.8 22227415 635. # … with 1,694 more rows ``` ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% * filter(year == 2002) ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 142 x 6 country continent year lifeExp pop gdpPercap <fct> <fct> <int> <dbl> <int> <dbl> 1 Afghanistan Asia 2002 42.1 25268405 727. 2 Albania Europe 2002 75.7 3508512 4604. 3 Algeria Africa 2002 71.0 31287142 5288. 4 Angola Africa 2002 41.0 10866106 2773. 5 Argentina Americas 2002 74.3 38331121 8798. 6 Australia Oceania 2002 80.4 19546792 30688. 7 Austria Europe 2002 79.0 8148312 32418. 8 Bahrain Asia 2002 74.8 656397 23404. 9 Bangladesh Asia 2002 62.0 135656790 1136. 10 Belgium Europe 2002 78.3 10311970 30486. # … with 132 more rows ``` ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% * ggplot() ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_04_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + * aes(x = lifeExp) ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_05_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + * aes(fill = continent) ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_06_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + * theme_minimal() ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_07_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + * geom_dotplot(alpha = .5) ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_08_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + geom_dotplot(alpha = .5) + * geom_rug(col = "darkgrey") ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_09_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + geom_dotplot(alpha = .5) + geom_rug(col = "darkgrey") + * labs(x = "Life Expectancy (Years)") ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_10_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + geom_dotplot(alpha = .5) + geom_rug(col = "darkgrey") + labs(x = "Life Expectancy (Years)") + * labs(y = "Count") ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_11_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + geom_dotplot(alpha = .5) + geom_rug(col = "darkgrey") + labs(x = "Life Expectancy (Years)") + labs(y = "Count") + * labs(title = "National Life Expectancy by Region", * subtitle = "Data from 2002") ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_12_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + geom_dotplot(alpha = .5) + geom_rug(col = "darkgrey") + labs(x = "Life Expectancy (Years)") + labs(y = "Count") + labs(title = "National Life Expectancy by Region", subtitle = "Data from 2002") + * facet_wrap(facets = vars(continent)) ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_13_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r library(gapminder) gapminder %>% filter(year == 2002) %>% ggplot() + aes(x = lifeExp) + aes(fill = continent) + theme_minimal() + geom_dotplot(alpha = .5) + geom_rug(col = "darkgrey") + labs(x = "Life Expectancy (Years)") + labs(y = "Count") + labs(title = "National Life Expectancy by Region", subtitle = "Data from 2002") + facet_wrap(facets = vars(continent)) + * theme(legend.position = "none") ``` ] .panel2-the_chunk-auto[ <img src="ex4.3_embed_files/figure-html/the_chunk_auto_14_output-1.png" width="576" /> ] <style> .panel1-the_chunk-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-the_chunk-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-the_chunk-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> <style type="text/css"> .remark-code{line-height: 1.5; font-size: 90%} @media print { .has-continuation { display: block; } } code.r.hljs.remark-code{ position: relative; overflow-x: hidden; } code.r.hljs.remark-code:hover{ overflow-x:visible; width: 500px; border-style: solid; } </style>