class: inverse, left, bottom background-image: url(https://images.unsplash.com/photo-1669147849966-534dc594fc85?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D) background-size: cover # .Large[# A featurette] ## .small[featuring [{ggnaturalearth}](https://github.com/EvaMaeRey/ggnaturalearth) - which exists to test and refine ggnorthcarolina, a template repo, and which makes some promising choropleths!] #### .tiny[Gina Reynolds | 2023-12-18 |Image credit: Martin Bennie, Upsplash] ??? Title --- count: false .panel1-feature-auto[ ```r *library(tidyverse) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) *library(ggnaturalearth) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) *options(scipen = 10) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) *gapminder::gapminder ``` ] .panel2-feature-auto[ ``` ## # A tibble: 1,704 × 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. ## # ℹ 1,694 more rows ``` ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> * filter(year == 2002) ``` ] .panel2-feature-auto[ ``` ## # A tibble: 142 × 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. ## # ℹ 132 more rows ``` ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% * ggplot() ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_06_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + * aes(country_name = country) ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_07_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + * geom_country() ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_08_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + * aes(fill = pop/1000000) ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_09_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + * labs(fill = "Pop (millions)") ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_10_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + labs(fill = "Pop (millions)") + * scale_fill_viridis_c(trans = "log10") ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_11_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + labs(fill = "Pop (millions)") + scale_fill_viridis_c(trans = "log10") + * aes(label = country) ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_12_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + labs(fill = "Pop (millions)") + scale_fill_viridis_c(trans = "log10") + aes(label = country) + * geom_country_label(size = 1.5, * check_overlap = T) ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_13_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + labs(fill = "Pop (millions)") + scale_fill_viridis_c(trans = "log10") + aes(label = country) + geom_country_label(size = 1.5, check_overlap = T) + * geom_country(keep_country = * c("Portugal", "Germany"), * color = "darkred", * linewidth = .5, * alpha = 0) ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_14_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + labs(fill = "Pop (millions)") + scale_fill_viridis_c(trans = "log10") + aes(label = country) + geom_country_label(size = 1.5, check_overlap = T) + geom_country(keep_country = c("Portugal", "Germany"), color = "darkred", linewidth = .5, alpha = 0) + * coord_sf(xlim = c(-25, 35), ylim = c(30, 80)) ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_15_output-1.png)<!-- --> ] --- count: false .panel1-feature-auto[ ```r library(tidyverse) library(ggnaturalearth) options(scipen = 10) gapminder::gapminder |> filter(year == 2002) %>% ggplot() + aes(country_name = country) + geom_country() + aes(fill = pop/1000000) + labs(fill = "Pop (millions)") + scale_fill_viridis_c(trans = "log10") + aes(label = country) + geom_country_label(size = 1.5, check_overlap = T) + geom_country(keep_country = c("Portugal", "Germany"), color = "darkred", linewidth = .5, alpha = 0) + coord_sf(xlim = c(-25, 35), ylim = c(30, 80)) + * ggstamp::theme_void_fill("aliceblue") ``` ] .panel2-feature-auto[ ![](ggnaturalearth_files/figure-html/feature_auto_16_output-1.png)<!-- --> ] <style> .panel1-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-feature-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- --- ### Contribute - https://github.com/EvaMaeRey/ggnorthcarolina --- ### Check out {rnaturalearth} which provides the underlying data - https://github.com/ropensci/rnaturalearth --- ### Check out flipbookr, used to build this featurette - https://github.com/EvaMaeRey/flipbookr - discussion: https://github.com/EvaMaeRey/flipbookr/blob/master/docs/draft_jasa_submission.pdf --- ### Check out more featurettes - https://EvaMaeRey.github.io/featurette <style type="text/css"> .remark-code{line-height: 1.5; font-size: 100%} @media print { .has-continuation { display: block; } } </style>