class: center, middle, inverse, title-slide # An Introduction: R + the
tidyverse
## For Dr. Abner’s Public Management Course
###
Matt Worthington
| Sr. Project Manager for Data Initiatives, UT Austin - LBJ ###
September 13, 2021
--- background-image: url('assets/images/analysis_screen1.png') background-size: cover --- class: middle, center <img src="intro_slides_files/figure-html/unnamed-chunk-2-1.png" width="1008" /> --- background-image: url('assets/images/dir_stat.png') background-size: cover class: center, bottom, inverse --- class: middle .pull-left[ # About Me ] .pull-right[ * .orange[**Personal Background**]: Born and raised in San Antonio, Texas. Live in Austin with my wife and three kids. * .orange[**Education Backgrounds**]: English Studies, Special Education, and Public Policy * .orange[**Professional Backgrounds**]: Public School Teacher, School District Administrator, and Data Scientist. ] --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_02.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_03.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('assets/images/hermione_spell_class.png') background-size: cover class: center, bottom, inverse ## .blue[How to understand R if you are new...] --- background-image: url('assets/images/hp_vs_r.png') background-size: cover class: center, bottom, inverse --- # How I Hope We End Today .pull-left[ #### Anywhere from here.. .rmd-img[] ] .pull-right[ #### to here. .rmd-img[] ] --- class: showcase-bg, section, center, middle # 🪄 Showcase --- # Census Spellbook: `tidycensus` .pull-left[ ```r library(tidycensus) # Create A List of Variables demvars <- c(White = "P005003", Black = "P005004", Asian = "P005006", Hispanic = "P004003") # Pull The Census Data harris <- get_decennial( geography = "tract", variables = demvars, state = "TX", county = "Harris County", geometry = TRUE, summary_var = "P001001" ) |> # Create pct column mutate(pct = 100 * (value / summary_value)) # Draw A Chart harris |> ggplot(aes(fill = pct)) + facet_wrap(~variable) + geom_sf(color = NA) + coord_sf(crs = 26915, datum=NA) + scale_fill_viridis_c() + theme_lbj() + labs(title="Population Demographics in Harris County", subtitle="US Census | 2010 Decennial Census") ``` ] .pull-right[ <img src="intro_slides_files/figure-html/unnamed-chunk-5-1.png" width="504" /> ] --- # Table Spellbook: `gt` .pull-left[ ```r library(gt) # Create A List of Variables demvars <- c(White = "P005003", Black = "P005004", Asian = "P005006", Hispanic = "P004003", AIAN = "P005005", NHOPI = "P005007", Other = "P003007",`Two or More` = "P003008") # Pull The Census Data harris <- get_decennial(geography = "county", variables = demvars, state = "TX", county = "Harris County", summary_var = "P001001") |> # Create pct column mutate(pct = (value / summary_value)) |> select(variable, value, pct) # Draw A Table harris |> gt() |> # Pass The Data To A gt table tab_header(title = md("**Demographics in Harris County**"), subtitle = "Harris County reported 4,092,459 residents in the 2010 Census. Here's how each demographic group compares to the total population.") |> tab_source_note(source_note = "Data: US Census | 2010 Decennial Census | pulled with {tidycensus} in R") |> fmt_number(columns = c("value")) |> fmt_percent(columns = c("pct")) |> cols_label( variable = md("**Group**"), value = md("**Population**"), pct = md("**Pct. of Total**") ) ``` ] .pull-right[
Demographics in Harris County
Harris County reported 4,092,459 residents in the 2010 Census. Here's how each demographic group compares to the total population.
Group
Population
Pct. of Total
White
1,349,646.00
32.98%
Black
754,258.00
18.43%
Asian
249,853.00
6.11%
Hispanic
1,671,540.00
40.84%
AIAN
8,150.00
0.20%
NHOPI
2,260.00
0.06%
Other
583,566.00
14.26%
Two or More
131,332.00
3.21%
Data: US Census | 2010 Decennial Census (pulled with {tidycensus} in R)
] --- # Static Charts: [`ggplot`]() .pull-left[  ] .pull-right[  ] --- # Interactive Charts: [`highcharter`](https://jkunst.com/highcharter/index.html)
--- # Dashboards: `shiny` .pull-left[ #### Texas Workforce Commission  ] .pull-right[ #### National Center for Farmworker Health  ] --- # Websites: `blogdown` + `distill` .pull-left[ .center[#### [Blogdown](https://pkgs.rstudio.com/blogdown/)]  ] .pull-right[ .center[#### [Distill](https://pkgs.rstudio.com/distill/)]  ] --- # Books: `bookdown` .rmd-img[] --- # Documents: `rmarkdown` .rmd-img[] --- # Like anything, this is a journey... .rmd-img[] --- class: journey-bg, section, center, middle, inverse # Let's get started 👟 --- # Downloading Materials .pull-left[ ### Today's Agenda .b--gray.ba.bw2.ma2.shadow-1[ * Navigating Rstudio * Rstudio Interface * R Projects * R Markdown - Markdown Text - Code Chunks * Creating Nice Reports * PDF * Word * HTML * Getting Data You Need * Things People Give You * Things That Live Online * Making Good Charts * Exporting Data & Charts ] ] .pull-right[ ### Today's Materials .b--gray.ba.bw2.ma2.pa2.shadow-1[ #### What You Should Download * [**Rmarkdown Analysis** ](tinyurl.com/TXVaxUptake): tinyurl.com/TXVaxUptake #### What You Should Reference Later * [**Today's Slides**](slides.lbjdata.org/course_workshops/abner/intro_r_workshop/intro_slide) * [**The Published Analysis**](https://demos.lbjdata.org/vaccine_uptake/analyzing-vacine-uptake) ] ] --- background-image: url('assets/images/rstudio_hex.png') background-size: cover class: center, bottom --- # Downloading The Materials * [**Rmarkdown Analysis** ](tinyurl.com/TXVaxUptake): tinyurl.com/TXVaxUptake  --- # Open the `.Rproj` file .rmd-img[] --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_17.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_18.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('assets/images/tidyverse_hex.png') background-size: cover class: center, bottom, inverse --- background-image: url('assets/images/tidyverse_network.png') background-size: cover class: center, bottom, inverse animated fadeIn --- background-image: url('assets/images/tidyverse_data_lifecycle_map.png') background-size: cover class: center, bottom, inverse animated fadeIn --- background-image: url('assets/images/lifecycle_focus.png') background-size: cover class: center, bottom, inverse animated fadeIn --- background-image: url('assets/images/what_todays_focus_will_be.png') background-size: cover class: center, bottom, inverse animated animate fadeIn --- background-image: url('assets/images/marie_kondo.png') background-size: cover class: center, bottom, inverse animated fadeIn --- # What is R Markdown? .pull-left.b--gray.ba.bw2.ma2.pa4.shadow-1[ * ["An authoring framework for data science."](https://rmarkdown.rstudio.com/lesson-1.html) (✔️) * [A document format (.Rmd)](https://bookdown.org/yihui/rmarkdown/). (✔️) * [An R package named rmarkdown](https://rmarkdown.rstudio.com/docs/). (✔️) * ["A file format for making dynamic documents with R."](https://rmarkdown.rstudio.com/articles_intro.html) (✔️) * ["A tool for integrating text, code, and results."](https://r4ds.had.co.nz/communicate-intro.html) (✔️) * ["A computational document."](http://radar.oreilly.com/2011/07/wolframs-computational-documen.html) (✔️) * Wizardry. (🧙️) ] .pull-right[ .rmd-small[] ] .tl.burntorange[ Courtesy of Alison Presmanes Hill ([@apreshill](https://twitter.com/apreshill)) ] --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_15.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_16.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_17.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_18.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_19.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_20.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_21.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_22.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_23.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_24.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_25.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_26.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_27.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_28.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_29.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_30.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_31.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_32.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_33.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_34.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_35.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_36.jpeg') background-size: cover class: center, bottom, inverse --- class: middle .pull-left[ ### Writing in Markdown If you're not familiar with Markdown, that's okay. If you're like me, you grew up using things like Microsoft Office and Google Docs to write, so you're probably not familiar with markdown, but Markdown is a lot easier. So... what is it? Markdown is just an easy way to write formatted text. Like anything else, it takes practice, but is used widely in popular writing apps like [Bear](https://bear.app), [iA Writer](https://ia.net/writer), [Ulysses](https://ulysses.app). For the purposes of this workshop, we'll use it in an RStudio document tool called "[Rmarkdown](https://rmarkdown.rstudio.com)". Here's a quick way to get familiar with writing in Markdown: .bg--burntorange.b--text-color.ba.bw2.br3.shadow-5.ph4.mt5.f7[ *__Note__: If writing in Markdown still feels weird, don't worry. You can also use R Markdown's Visual Markdown Editor.* ] ] .pull-right[  * **First, visit this link:** Go to [https://commonmark.org/help/tutorial/](https://commonmark.org/help/tutorial/) * **Then, do the 10-minute tutorial:** It's a bit of time, but goes quick and will help you have a better grasp on writing in markdown. * **Finally, bookmark this site**: [https://commonmark.org/help/](https://commonmark.org/help/) ] --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_38.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_39.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_40.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_41.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_42.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_43.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_44.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_45.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_46.jpeg') background-size: cover class: center, bottom, inverse --- background-image: url('https://utexas-lbjp-data.github.io/assets/rmarkdown/slide_47.jpeg') background-size: cover class: center, bottom, inverse --- class: title center pipe-page # `|>` and `%>%` <code class ='r hljs remark-code'><b>leave_house</b>(<b>get_dressed</b>(<b>get_out_of_bed</b>(<b>wake_up</b>(<span style='color:#bf5700'>me</span>, <span style='color:#005f86'>time</span> = <span style='color:#bf5700'>"8:00"</span>), <span style='color:#005f86'>side</span> = <span style='color:#bf5700'>"correct"</span>), <span style='color:#005f86'>pants</span> = <span style='color:#bf5700'>TRUE</span>, <span style='color:#005f86'>shirt</span> = <span style='color:#bf5700'>TRUE</span>), <span style='color:#005f86'>car</span> = <span style='color:#bf5700'>TRUE</span>, <span style='color:#005f86'>bike</span> = <span style='color:#bf5700'>FALSE</span>)</code> -- <code class ='r hljs remark-code'>me <span style='background-color:#ffff7f'>|></span> <br> <b>wake_up</b>(<span style='color:#005f86'>time</span> = <span style='color:#bf5700'>"8:00"</span>) <span style='background-color:#ffff7f'>|></span> <br> <b>get_out_of_bed</b>(<span style='color:#005f86'>side</span> = <span style='color:#bf5700'>"correct"</span>) <span style='background-color:#ffff7f'>|></span> <br> <b>get_dressed</b>(<span style='color:#005f86'>pants</span> = <span style='color:#bf5700'>TRUE</span>, <span style='color:#005f86'>shirt</span> = <span style='color:#bf5700'>TRUE</span>) <span style='background-color:#ffff7f'>|></span> <br> <b>leave_house</b>(<span style='color:#005f86'>car</span> = <span style='color:#bf5700'>TRUE</span>, <span style='color:#005f86'>bike</span> = <span style='color:#bf5700'>FALSE</span>)</code> .tl.footnote-small[ Courtesy of Andrew Heiss ([@andrewheiss](https://twitter.com/andrewheiss)) ] --- class: vaccine-bg, section, center, middle, inverse # And Now... The Analysis --- # Package Setup Under the **Analysis Setup** section, there's a chunk tagged `setup` that starts on line 32. ```r knitr::opts_chunk$set(warning = FALSE, message = FALSE) # In case these aren't installed already from the prework, uncomment the next three lines and run them. # install.packages(c("rmarkdown", "tidyverse", "tidycensus", "distill", "devtools")) # install.packages(c("janitor", "readxl")) # devtools::install_github("utexas-lbjp-data/lbjdata") library(janitor) # Package with useful + convenient data cleaning functions library(readxl) # Package with useful functions for working with Excel Files library(tidyverse) # Core Set of R Data Science Tools (dplyr, ggplot2, tidyr, readr, etc.) library(lbjdata) # LBJ Data Package which has the ggplot2 themes ``` -- ### What's happening here? .b--burntorange.ba.bw2.ma2.pa2.shadow-1[ Whenever you see `library(...)`, it means we are loading the packages into our Rmarkdown document so we can use the functions inside of them? In other words, we're pulling out the spellbooks and getting ready to do some data magic. ] --- ## `janitor::clean_names()` **What it does:** Makes all column names machine readble (huge time saver): .rmd-small[] .tl.burntorange[ Credit: ([@allison_horst](https://twitter.com/allison_horst)) ] --- # Importing Our Data .pull-left[ **Step 1: Downloading Our Data** ```r vax_url <- "https://dshs.texas.gov/immunize/covid19/COVID-19-Vaccine-Data-by-County.xls" download.file(url=vax_url, destfile = "raw_data/tx_vaccine_uptake.xlsx") ``` **Step 2: Import the Downloaded Data** ```r vaccine_data_raw <- readxl::read_excel(path = "raw_data/tx_vaccine_uptake.xlsx", sheet = "By County") |> janitor::clean_names() # This function makes column headers machine readable dplyr::glimpse(vaccine_data_raw) # glimpse() lets you preview a data object ``` ] .pull-right[ .rmd-img[] ] --- count: false # Importing - step by step view .panel1-import-data-real-auto[ ```r *readxl::read_excel(path = "raw_data/tx_vaccine_uptake.xlsx", * sheet = "By County") ``` ] .panel2-import-data-real-auto[ ``` # A tibble: 259 × 13 `County Name` `Public Health Reg… `Total Doses All… `Vaccine Doses Ad… <chr> <chr> <dbl> <chr> 1 Texas -- 27513735 29823734 2 Federal Long-Term C… -- 720525 -- 3 Federal Pharmacy Re… -- 5509700 -- 4 Anderson 4/5N 17870 39858 5 Andrews 9/10 6100 14186 6 Angelina 4/5N 58100 66563 7 Aransas 11 6840 25549 8 Archer 2/3 3200 7005 9 Armstrong 1 2100 1272 10 Atascosa 8 19000 43015 # … with 249 more rows, and 9 more variables: # People Vaccinated with at least One Dose <chr>, # People Fully Vaccinated <chr>, Population 12+ <chr>, Population, 16+ <chr>, # Population, 65+ <chr>, Population, Phase 1A Healthcare Workers <chr>, # Population, Phase 1A Long-term Care Residents <chr>, # Population, 16-64 Any Medical Condition <chr>, # Population, Education and Child Care Personnel <chr> ``` ] --- count: false # Importing - step by step view .panel1-import-data-real-auto[ ```r readxl::read_excel(path = "raw_data/tx_vaccine_uptake.xlsx", sheet = "By County") %>% * janitor::clean_names() ``` ] .panel2-import-data-real-auto[ ``` # A tibble: 259 × 13 county_name public_health_regi… total_doses_allo… vaccine_doses_adm… <chr> <chr> <dbl> <chr> 1 Texas -- 27513735 29823734 2 Federal Long-Term C… -- 720525 -- 3 Federal Pharmacy Re… -- 5509700 -- 4 Anderson 4/5N 17870 39858 5 Andrews 9/10 6100 14186 6 Angelina 4/5N 58100 66563 7 Aransas 11 6840 25549 8 Archer 2/3 3200 7005 9 Armstrong 1 2100 1272 10 Atascosa 8 19000 43015 # … with 249 more rows, and 9 more variables: # people_vaccinated_with_at_least_one_dose <chr>, # people_fully_vaccinated <chr>, population_12 <chr>, population_16 <chr>, # population_65 <chr>, population_phase_1a_healthcare_workers <chr>, # population_phase_1a_long_term_care_residents <chr>, # population_16_64_any_medical_condition <chr>, # population_education_and_child_care_personnel <chr> ``` ] --- count: false # Importing - step by step view .panel1-import-data-real-auto[ ```r readxl::read_excel(path = "raw_data/tx_vaccine_uptake.xlsx", sheet = "By County") %>% janitor::clean_names() ``` ] .panel2-import-data-real-auto[ ``` # A tibble: 259 × 13 county_name public_health_regi… total_doses_allo… vaccine_doses_adm… <chr> <chr> <dbl> <chr> 1 Texas -- 27513735 29823734 2 Federal Long-Term C… -- 720525 -- 3 Federal Pharmacy Re… -- 5509700 -- 4 Anderson 4/5N 17870 39858 5 Andrews 9/10 6100 14186 6 Angelina 4/5N 58100 66563 7 Aransas 11 6840 25549 8 Archer 2/3 3200 7005 9 Armstrong 1 2100 1272 10 Atascosa 8 19000 43015 # … with 249 more rows, and 9 more variables: # people_vaccinated_with_at_least_one_dose <chr>, # people_fully_vaccinated <chr>, population_12 <chr>, population_16 <chr>, # population_65 <chr>, population_phase_1a_healthcare_workers <chr>, # population_phase_1a_long_term_care_residents <chr>, # population_16_64_any_medical_condition <chr>, # population_education_and_child_care_personnel <chr> ``` ] <style> .panel1-import-data-real-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-import-data-real-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-import-data-real-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- ## `dplyr::select()` **What it does:** Selects your preferred columns from your data set. <iframe width="750" height = "416" src="https://video.twimg.com/tweet_video/E-D3IWxWYAEIk51.mp4" frameborder="0" style = "border: solid 0px #ffffff" color = "white" modestbranding = "1" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen data-external="1"></iframe> .tl.burntorange[ Credit: ([@illustratedbyte](https://twitter.com/illustratedbyte)) ] --- ## `dplyr::mutate()` **What it does:** Creates or transforms a variable (column) while keeping the existing ones: .rmd-tiny[] .tl.burntorange[ Credit: ([@allison_horst](https://twitter.com/allison_horst)) ] --- ## `dplyr::filter()` **What it does:** Subsets rows based on your conditions .rmd-small[] .tl.burntorange[ Credit: ([@allison_horst](https://twitter.com/allison_horst)) ] --- # Working With Our Data ### Step 1 ```r vaccine_uptake <- vaccine_data_raw %>% select(county_name, people_fully_vaccinated, population_12) %>% # Pull the three columns we need mutate(people_fully_vaccinated = as.numeric(people_fully_vaccinated), # Reclassify Character Data As Numeric population_12 = as.numeric(population_12)) %>% mutate(pct_uptake = round(people_fully_vaccinated/population_12, digits = 4)) %>% # Create PCT Column filter(county_name!="Texas", # Filter out 'Texas' value county_name!="Other", # Filter our 'Other' value county_name!="Federal Long-Term Care Vaccination Program", # Filter our Federal Programs county_name!="Federal Pharmacy Retail Vaccination Program") ``` ``` # A tibble: 254 × 4 county_name people_fully_vaccinated population_12 pct_uptake <chr> <dbl> <dbl> <dbl> 1 Anderson 19254 50661 0.380 2 Andrews 6589 14863 0.443 3 Angelina 31593 72486 0.436 4 Aransas 12099 20834 0.581 5 Archer 3459 7388 0.468 6 Armstrong 597 1584 0.377 7 Atascosa 20178 41738 0.483 8 Austin 12388 25335 0.489 9 Bailey 2274 5603 0.406 10 Bandera 8709 20596 0.423 # … with 244 more rows ``` --- count: false # Working with Data - Step 1 .panel1-create-pct-column-real-auto[ ```r *vaccine_data_raw ``` ] .panel2-create-pct-column-real-auto[ ``` # A tibble: 259 × 13 county_name public_health_regi… total_doses_allo… vaccine_doses_adm… <chr> <chr> <dbl> <chr> 1 Texas -- 27513735 29823734 2 Federal Long-Term C… -- 720525 -- 3 Federal Pharmacy Re… -- 5509700 -- 4 Anderson 4/5N 17870 39858 5 Andrews 9/10 6100 14186 6 Angelina 4/5N 58100 66563 7 Aransas 11 6840 25549 8 Archer 2/3 3200 7005 9 Armstrong 1 2100 1272 10 Atascosa 8 19000 43015 # … with 249 more rows, and 9 more variables: # people_vaccinated_with_at_least_one_dose <chr>, # people_fully_vaccinated <chr>, population_12 <chr>, population_16 <chr>, # population_65 <chr>, population_phase_1a_healthcare_workers <chr>, # population_phase_1a_long_term_care_residents <chr>, # population_16_64_any_medical_condition <chr>, # population_education_and_child_care_personnel <chr> ``` ] --- count: false # Working with Data - Step 1 .panel1-create-pct-column-real-auto[ ```r vaccine_data_raw %>% * select(county_name, people_fully_vaccinated, population_12) # Pull the three columns we need ``` ] .panel2-create-pct-column-real-auto[ ``` # A tibble: 259 × 3 county_name people_fully_vacci… population_12 <chr> <chr> <chr> 1 Texas 14183523 24068624 2 Federal Long-Term Care Vaccination Program -- -- 3 Federal Pharmacy Retail Vaccination Program -- -- 4 Anderson 19254 50661 5 Andrews 6589 14863 6 Angelina 31593 72486 7 Aransas 12099 20834 8 Archer 3459 7388 9 Armstrong 597 1584 10 Atascosa 20178 41738 # … with 249 more rows ``` ] --- count: false # Working with Data - Step 1 .panel1-create-pct-column-real-auto[ ```r vaccine_data_raw %>% select(county_name, people_fully_vaccinated, population_12) %>% # Pull the three columns we need * mutate(people_fully_vaccinated = as.numeric(people_fully_vaccinated), # Reclassify Character Data As Numeric * population_12 = as.numeric(population_12)) ``` ] .panel2-create-pct-column-real-auto[ ``` # A tibble: 259 × 3 county_name people_fully_vacci… population_12 <chr> <dbl> <dbl> 1 Texas 14183523 24068624 2 Federal Long-Term Care Vaccination Program NA NA 3 Federal Pharmacy Retail Vaccination Program NA NA 4 Anderson 19254 50661 5 Andrews 6589 14863 6 Angelina 31593 72486 7 Aransas 12099 20834 8 Archer 3459 7388 9 Armstrong 597 1584 10 Atascosa 20178 41738 # … with 249 more rows ``` ] --- count: false # Working with Data - Step 1 .panel1-create-pct-column-real-auto[ ```r vaccine_data_raw %>% select(county_name, people_fully_vaccinated, population_12) %>% # Pull the three columns we need mutate(people_fully_vaccinated = as.numeric(people_fully_vaccinated), # Reclassify Character Data As Numeric population_12 = as.numeric(population_12)) %>% * mutate(pct_uptake = round(people_fully_vaccinated/population_12, digits = 4)) # Create PCT Column ``` ] .panel2-create-pct-column-real-auto[ ``` # A tibble: 259 × 4 county_name people_fully_vaccin… population_12 pct_uptake <chr> <dbl> <dbl> <dbl> 1 Texas 14183523 24068624 0.589 2 Federal Long-Term Care Vaccina… NA NA NA 3 Federal Pharmacy Retail Vaccin… NA NA NA 4 Anderson 19254 50661 0.380 5 Andrews 6589 14863 0.443 6 Angelina 31593 72486 0.436 7 Aransas 12099 20834 0.581 8 Archer 3459 7388 0.468 9 Armstrong 597 1584 0.377 10 Atascosa 20178 41738 0.483 # … with 249 more rows ``` ] --- count: false # Working with Data - Step 1 .panel1-create-pct-column-real-auto[ ```r vaccine_data_raw %>% select(county_name, people_fully_vaccinated, population_12) %>% # Pull the three columns we need mutate(people_fully_vaccinated = as.numeric(people_fully_vaccinated), # Reclassify Character Data As Numeric population_12 = as.numeric(population_12)) %>% mutate(pct_uptake = round(people_fully_vaccinated/population_12, digits = 4)) %>% # Create PCT Column * filter(county_name!="Texas", # Filter out 'Texas' value * county_name!="Other", # Filter our 'Other' value * county_name!="Federal Long-Term Care Vaccination Program", # Filter our Federal Programs * county_name!="Federal Pharmacy Retail Vaccination Program") ``` ] .panel2-create-pct-column-real-auto[ ``` # A tibble: 254 × 4 county_name people_fully_vaccinated population_12 pct_uptake <chr> <dbl> <dbl> <dbl> 1 Anderson 19254 50661 0.380 2 Andrews 6589 14863 0.443 3 Angelina 31593 72486 0.436 4 Aransas 12099 20834 0.581 5 Archer 3459 7388 0.468 6 Armstrong 597 1584 0.377 7 Atascosa 20178 41738 0.483 8 Austin 12388 25335 0.489 9 Bailey 2274 5603 0.406 10 Bandera 8709 20596 0.423 # … with 244 more rows ``` ] <style> .panel1-create-pct-column-real-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-create-pct-column-real-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-create-pct-column-real-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Working With Our Data ### Step 2 ```r ranked_uptake <- vaccine_uptake %>% # Create New Object mutate(uptake_rank = dense_rank(desc(pct_uptake))) %>% # Create Rank Column filter(uptake_rank <= 10) %>% # Filter only for Top 10 counties arrange(uptake_rank) # Sort by rank ``` ``` # A tibble: 10 × 5 county_name people_fully_vaccinated population_12 pct_uptake uptake_rank <chr> <dbl> <dbl> <dbl> <int> 1 Presidio 5182 5392 0.961 1 2 Webb 182570 215919 0.846 2 3 Starr 41696 49864 0.836 3 4 Cameron 260316 339698 0.766 4 5 Maverick 35051 46417 0.755 5 6 Hidalgo 511412 681678 0.750 6 7 El Paso 512785 688420 0.745 7 8 Fort Bend 484674 665167 0.729 8 9 Travis 750079 1092827 0.686 9 10 Hudspeth 2822 4139 0.682 10 ``` --- count: false # Working with Data - Step 2 .panel1-rank-and-limit-real-auto[ ```r *vaccine_uptake # Create New Object ``` ] .panel2-rank-and-limit-real-auto[ ``` # A tibble: 254 × 4 county_name people_fully_vaccinated population_12 pct_uptake <chr> <dbl> <dbl> <dbl> 1 Anderson 19254 50661 0.380 2 Andrews 6589 14863 0.443 3 Angelina 31593 72486 0.436 4 Aransas 12099 20834 0.581 5 Archer 3459 7388 0.468 6 Armstrong 597 1584 0.377 7 Atascosa 20178 41738 0.483 8 Austin 12388 25335 0.489 9 Bailey 2274 5603 0.406 10 Bandera 8709 20596 0.423 # … with 244 more rows ``` ] --- count: false # Working with Data - Step 2 .panel1-rank-and-limit-real-auto[ ```r vaccine_uptake %>% # Create New Object * mutate(uptake_rank = dense_rank(desc(pct_uptake))) # Create Rank Column ``` ] .panel2-rank-and-limit-real-auto[ ``` # A tibble: 254 × 5 county_name people_fully_vaccinated population_12 pct_uptake uptake_rank <chr> <dbl> <dbl> <dbl> <int> 1 Anderson 19254 50661 0.380 181 2 Andrews 6589 14863 0.443 99 3 Angelina 31593 72486 0.436 109 4 Aransas 12099 20834 0.581 32 5 Archer 3459 7388 0.468 79 6 Armstrong 597 1584 0.377 187 7 Atascosa 20178 41738 0.483 68 8 Austin 12388 25335 0.489 65 9 Bailey 2274 5603 0.406 147 10 Bandera 8709 20596 0.423 127 # … with 244 more rows ``` ] --- count: false # Working with Data - Step 2 .panel1-rank-and-limit-real-auto[ ```r vaccine_uptake %>% # Create New Object mutate(uptake_rank = dense_rank(desc(pct_uptake))) %>% # Create Rank Column * filter(uptake_rank <= 10) # Filter only for Top 10 counties ``` ] .panel2-rank-and-limit-real-auto[ ``` # A tibble: 10 × 5 county_name people_fully_vaccinated population_12 pct_uptake uptake_rank <chr> <dbl> <dbl> <dbl> <int> 1 Cameron 260316 339698 0.766 4 2 El Paso 512785 688420 0.745 7 3 Fort Bend 484674 665167 0.729 8 4 Hidalgo 511412 681678 0.750 6 5 Hudspeth 2822 4139 0.682 10 6 Maverick 35051 46417 0.755 5 7 Presidio 5182 5392 0.961 1 8 Starr 41696 49864 0.836 3 9 Travis 750079 1092827 0.686 9 10 Webb 182570 215919 0.846 2 ``` ] --- count: false # Working with Data - Step 2 .panel1-rank-and-limit-real-auto[ ```r vaccine_uptake %>% # Create New Object mutate(uptake_rank = dense_rank(desc(pct_uptake))) %>% # Create Rank Column filter(uptake_rank <= 10) %>% # Filter only for Top 10 counties * arrange(uptake_rank) # Sort by rank ``` ] .panel2-rank-and-limit-real-auto[ ``` # A tibble: 10 × 5 county_name people_fully_vaccinated population_12 pct_uptake uptake_rank <chr> <dbl> <dbl> <dbl> <int> 1 Presidio 5182 5392 0.961 1 2 Webb 182570 215919 0.846 2 3 Starr 41696 49864 0.836 3 4 Cameron 260316 339698 0.766 4 5 Maverick 35051 46417 0.755 5 6 Hidalgo 511412 681678 0.750 6 7 El Paso 512785 688420 0.745 7 8 Fort Bend 484674 665167 0.729 8 9 Travis 750079 1092827 0.686 9 10 Hudspeth 2822 4139 0.682 10 ``` ] --- count: false # Working with Data - Step 2 .panel1-rank-and-limit-real-auto[ ```r vaccine_uptake %>% # Create New Object mutate(uptake_rank = dense_rank(desc(pct_uptake))) %>% # Create Rank Column filter(uptake_rank <= 10) %>% # Filter only for Top 10 counties arrange(uptake_rank) # Sort by rank ``` ] .panel2-rank-and-limit-real-auto[ ``` # A tibble: 10 × 5 county_name people_fully_vaccinated population_12 pct_uptake uptake_rank <chr> <dbl> <dbl> <dbl> <int> 1 Presidio 5182 5392 0.961 1 2 Webb 182570 215919 0.846 2 3 Starr 41696 49864 0.836 3 4 Cameron 260316 339698 0.766 4 5 Maverick 35051 46417 0.755 5 6 Hidalgo 511412 681678 0.750 6 7 El Paso 512785 688420 0.745 7 8 Fort Bend 484674 665167 0.729 8 9 Travis 750079 1092827 0.686 9 10 Hudspeth 2822 4139 0.682 10 ``` ] <style> .panel1-rank-and-limit-real-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-rank-and-limit-real-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-rank-and-limit-real-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # The Basics of a ggplot2 chart .pull-left[ ```r library(ggplot2) library(ggthemes) diamonds |> # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped geom_bar(show.legend = FALSE) + # Define What Kind of Chart to Draw labs( x = "Cut", # Specify X-Axis Label y = "Count", # Specify Y-Axis Label title = "A Fancy diamonds Plot", # Specify Title Label subtitle = "A compelling subtitle", # Specify Subtitle Label caption = "Source: ggplot2 package | Data: 'diamonds'" # Specify Source/Caption Label ) + theme_lbj() + # Add The LBJ Theme theme(plot.title = element_text(color = "#bf5700")) + # Modify Title's Color ggthemes::scale_fill_tableau(palette = "Color Blind") # Add A Color Blind Friendly Palette ``` ] .pull-right[ <img src="intro_slides_files/figure-html/fancy_diamonds-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r *library(ggplot2) ``` ] .panel2-fancy_diamonds-auto[ ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) *library(ggthemes) ``` ] .panel2-fancy_diamonds-auto[ ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) *diamonds # Call On Your Dataset ``` ] .panel2-fancy_diamonds-auto[ ``` # A tibble: 53,940 × 10 carat cut color clarity depth table price x y z <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl> 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39 # … with 53,930 more rows ``` ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset * ggplot() # Draw A Canvas ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_04_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas * aes(cut, fill = cut) # Define How The Data Gets Mapped ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_05_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped * geom_bar(show.legend = FALSE) # Define What Kind of Chart to Draw ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_06_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped geom_bar(show.legend = FALSE) + # Define What Kind of Chart to Draw * labs( * x = "Cut", # Specify X-Axis Label * y = "Count", # Specify Y-Axis Label * title = "A Fancy diamonds Plot", # Specify Title Label * subtitle = "A compelling subtitle", # Specify Subtitle Label * caption = "Source: ggplot2 package | Data: 'diamonds'" # Specify Source/Caption Label * ) ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_07_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped geom_bar(show.legend = FALSE) + # Define What Kind of Chart to Draw labs( x = "Cut", # Specify X-Axis Label y = "Count", # Specify Y-Axis Label title = "A Fancy diamonds Plot", # Specify Title Label subtitle = "A compelling subtitle", # Specify Subtitle Label caption = "Source: ggplot2 package | Data: 'diamonds'" # Specify Source/Caption Label ) + * theme_lbj() # Add The LBJ Theme ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_08_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped geom_bar(show.legend = FALSE) + # Define What Kind of Chart to Draw labs( x = "Cut", # Specify X-Axis Label y = "Count", # Specify Y-Axis Label title = "A Fancy diamonds Plot", # Specify Title Label subtitle = "A compelling subtitle", # Specify Subtitle Label caption = "Source: ggplot2 package | Data: 'diamonds'" # Specify Source/Caption Label ) + theme_lbj() + # Add The LBJ Theme * theme(plot.title = element_text(color = "#bf5700")) # Modify Title's Color ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_09_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped geom_bar(show.legend = FALSE) + # Define What Kind of Chart to Draw labs( x = "Cut", # Specify X-Axis Label y = "Count", # Specify Y-Axis Label title = "A Fancy diamonds Plot", # Specify Title Label subtitle = "A compelling subtitle", # Specify Subtitle Label caption = "Source: ggplot2 package | Data: 'diamonds'" # Specify Source/Caption Label ) + theme_lbj() + # Add The LBJ Theme theme(plot.title = element_text(color = "#bf5700")) + # Modify Title's Color * scale_fill_tableau(palette = "Color Blind") # Add A Color Blind Friendly Palette ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_10_output-1.png" width="504" /> ] --- count: false # A step by step view .panel1-fancy_diamonds-auto[ ```r library(ggplot2) library(ggthemes) diamonds %>% # Call On Your Dataset ggplot() + # Draw A Canvas aes(cut, fill = cut) + # Define How The Data Gets Mapped geom_bar(show.legend = FALSE) + # Define What Kind of Chart to Draw labs( x = "Cut", # Specify X-Axis Label y = "Count", # Specify Y-Axis Label title = "A Fancy diamonds Plot", # Specify Title Label subtitle = "A compelling subtitle", # Specify Subtitle Label caption = "Source: ggplot2 package | Data: 'diamonds'" # Specify Source/Caption Label ) + theme_lbj() + # Add The LBJ Theme theme(plot.title = element_text(color = "#bf5700")) + # Modify Title's Color scale_fill_tableau(palette = "Color Blind") # Add A Color Blind Friendly Palette ``` ] .panel2-fancy_diamonds-auto[ <img src="intro_slides_files/figure-html/fancy_diamonds_auto_11_output-1.png" width="504" /> ] <style> .panel1-fancy_diamonds-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-fancy_diamonds-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-fancy_diamonds-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Visualizing Our Data .pull-left[ ```r uptake_chart <- ggplot(ranked_uptake) + aes(x=county_name, y = pct_uptake, fill=pct_uptake) + geom_col() + labs(title = "Leaders of the Vax", subtitle = "Top 10 Counties in Texas for Vaccine Uptake", x = "Vaccine Uptake (%)", y = "County") + lbjdata::theme_lbj(base_size = 10) ``` ] .pull-right[ <img src="intro_slides_files/figure-html/draw-viz-real-1.png" width="504" /> ] --- count: false # Visualizing our Data .panel1-draw-viz-real-auto[ ```r *ggplot(ranked_uptake) ``` ] .panel2-draw-viz-real-auto[ <img src="intro_slides_files/figure-html/draw-viz-real_auto_01_output-1.png" width="504" /> ] --- count: false # Visualizing our Data .panel1-draw-viz-real-auto[ ```r ggplot(ranked_uptake) + * aes(x=county_name, y = pct_uptake, fill=pct_uptake) ``` ] .panel2-draw-viz-real-auto[ <img src="intro_slides_files/figure-html/draw-viz-real_auto_02_output-1.png" width="504" /> ] --- count: false # Visualizing our Data .panel1-draw-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=county_name, y = pct_uptake, fill=pct_uptake) + * geom_col() ``` ] .panel2-draw-viz-real-auto[ <img src="intro_slides_files/figure-html/draw-viz-real_auto_03_output-1.png" width="504" /> ] --- count: false # Visualizing our Data .panel1-draw-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=county_name, y = pct_uptake, fill=pct_uptake) + geom_col() + * labs(title = "Leaders of the Vax", * subtitle = "Top 10 Counties in Texas for Vaccine Uptake", * x = "Vaccine Uptake (%)", * y = "County") ``` ] .panel2-draw-viz-real-auto[ <img src="intro_slides_files/figure-html/draw-viz-real_auto_04_output-1.png" width="504" /> ] --- count: false # Visualizing our Data .panel1-draw-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=county_name, y = pct_uptake, fill=pct_uptake) + geom_col() + labs(title = "Leaders of the Vax", subtitle = "Top 10 Counties in Texas for Vaccine Uptake", x = "Vaccine Uptake (%)", y = "County") + * lbjdata::theme_lbj(base_size = 10) ``` ] .panel2-draw-viz-real-auto[ <img src="intro_slides_files/figure-html/draw-viz-real_auto_05_output-1.png" width="504" /> ] --- count: false # Visualizing our Data .panel1-draw-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=county_name, y = pct_uptake, fill=pct_uptake) + geom_col() + labs(title = "Leaders of the Vax", subtitle = "Top 10 Counties in Texas for Vaccine Uptake", x = "Vaccine Uptake (%)", y = "County") + lbjdata::theme_lbj(base_size = 10) ``` ] .panel2-draw-viz-real-auto[ <img src="intro_slides_files/figure-html/draw-viz-real_auto_06_output-1.png" width="504" /> ] <style> .panel1-draw-viz-real-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-draw-viz-real-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-draw-viz-real-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Sorting Our Chart .pull-left[ ```r uptake_sorted <- ggplot(ranked_uptake) + aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) + geom_col() + scale_y_continuous(labels = scales::percent) + labs(title = "Leaders of the Vax", subtitle = "Top 10 Counties in Texas for Vaccine Uptake", x = "Vaccine Uptake (%)", y = "County") + lbjdata::theme_lbj(base_family = "Libre Franklin", base_size = 10) ``` ] .pull-right[ <img src="intro_slides_files/figure-html/sorting-viz-real-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r *ggplot(ranked_uptake) ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_01_output-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r ggplot(ranked_uptake) + * aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_02_output-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) + * geom_col() ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_03_output-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) + geom_col() + * scale_y_continuous(labels = scales::percent) ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_04_output-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) + geom_col() + scale_y_continuous(labels = scales::percent) + * labs(title = "Leaders of the Vax", * subtitle = "Top 10 Counties in Texas for Vaccine Uptake", * x = "Vaccine Uptake (%)", * y = "County") ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_05_output-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) + geom_col() + scale_y_continuous(labels = scales::percent) + labs(title = "Leaders of the Vax", subtitle = "Top 10 Counties in Texas for Vaccine Uptake", x = "Vaccine Uptake (%)", y = "County") + * lbjdata::theme_lbj(base_family = "Libre Franklin", base_size = 10) ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_06_output-1.png" width="504" /> ] --- count: false # Sorting Our Chart .panel1-sorting-viz-real-auto[ ```r ggplot(ranked_uptake) + aes(x=reorder(county_name, uptake_rank), y = pct_uptake, fill=pct_uptake) + geom_col() + scale_y_continuous(labels = scales::percent) + labs(title = "Leaders of the Vax", subtitle = "Top 10 Counties in Texas for Vaccine Uptake", x = "Vaccine Uptake (%)", y = "County") + lbjdata::theme_lbj(base_family = "Libre Franklin", base_size = 10) ``` ] .panel2-sorting-viz-real-auto[ <img src="intro_slides_files/figure-html/sorting-viz-real_auto_07_output-1.png" width="504" /> ] <style> .panel1-sorting-viz-real-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-sorting-viz-real-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-sorting-viz-real-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Exporting Our Data ### Step 1: Export Our Chart ```r ggsave("vaccine_uptake_chart.png", uptake_sorted, dpi = 300, width = 10, height = 6, bg = "white") ``` ### Step 2: Export Our Data ```r write_csv(ranked_uptake, "vaccine_uptake_top_10.csv") ``` --- class: journey-bg, section, left, middle, inverse # 📚 Resources 📚 ## Questions? lbjdata.org #### [#rstats hashtag](https://twitter.com/search?q=%23rstats) on twitter #### R For Data Science - [Online Book](https://r4ds.had.co.nz) | [Hard Copy](https://www.oreilly.com/library/view/r-for-data/9781491910382/) | [Slack Community](https://www.rfordatasci.com) --- class: journey-bg, section, center, middle, inverse # 🙏 Thank you 🙏 ## Questions? lbjdata.org ### 📧: matthew.worthington@austin.utexas.edu ### 🐦: @mrworthington