TidyCensus
Kyle Walker’s tutorials introduce TidyCensus in R.
Here is a bar graph showing median income for Story, Grundy, Chickasaw, and Buchanan counties. Also included is each estimate’s margin of error.
library (tidycensus)
library (ggplot2)
library (tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ lubridate 1.9.2 ✔ tibble 3.2.1
✔ purrr 1.0.1 ✔ tidyr 1.3.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
median_income <- get_acs (
geography = "county" ,
variables = "B19013_001" ,
year = 2021
)
Getting data from the 2017-2021 5-year ACS
winvest_counties <- get_acs (
geography = 'county' ,
state = 'IA' ,
county = c ('Story' , 'Grundy' , 'Chickasaw' , 'Buchanan' ),
variables = "B19013_001" ,
year = 2021 ,
survey = 'acs5'
)
Getting data from the 2017-2021 5-year ACS
ggplot (winvest_counties, aes (y = estimate, x = NAME)) +
ggtitle ("Median Income" )+
geom_bar (stat= "identity" , color = "#3182bd" , fill= "#9ecae1" )+ labs (x= "county name" ,y= "dollars" )+
scale_x_discrete (labels = function (x) str_remove (x, " County, Iowa|, Iowa" ))+
geom_errorbar (aes (ymin = estimate - moe, ymax = estimate + moe),
width = 0.5 , linewidth = 0.5 )
GitHub and Blogs
We also had a GitHub workshop this week to get familiar with GitHub actions. I created my own folder and ReadMe in the DSPG2023 Repo. We also created blogs using quarto/ RStudio.
Things to Work On
Setting up everything, especially the blog posts took a while and I had trouble with getting my changes to show up on GitHub. Thankfully I was able to get help and eventually got everything to show up correctly. I am looking forward to improving my blog pages and trying new things.