Assignment 6

Author

Matthew Albano

Open the assign06.qmd file and complete the exercises.

This is a very open-ended assignment. There are three musts:

  1. You must use the tidycensus package to get either decennial or ACS data from the US Census Bureau.

  2. You must get data for two different variables and they can’t be population or median home values.

  3. You must show all the code you used to get the data and create the table or chart.

You can then either create a cool table or chart comparing the two variables. They can be from any region and for any geography…it doesn’t necessarily need to be Maine.

Note: you will receive deductions for not using tidyverse syntax in this assignment. That includes the use of filter, mutate, and the up-to-date pipe operator |>.

The Grading Rubric is available at the end of this document.

We’ll preload the following potentially useful packages

library(tidyverse)
library(tidycensus)
library(gapminder)
library(gt)
library(gtExtras)
library(scales)

This is your work area. Add as many code cells as you need.

census_api_key("e9fd794033f66bfe324f72b8e97d6d5519ded9c7")
To install your API key for use in future sessions, run this function with `install = TRUE`.
acs_data_me <- get_acs(
  geography = "county",
  variables = "B15003_022",
  state = "ME",
  year = 2023
)
Getting data from the 2019-2023 5-year ACS
acs_data_me |> gt()
GEOID NAME variable estimate moe
23001 Androscoggin County, Maine B15003_022 12348 766
23003 Aroostook County, Maine B15003_022 7765 631
23005 Cumberland County, Maine B15003_022 70012 1960
23007 Franklin County, Maine B15003_022 4289 393
23009 Hancock County, Maine B15003_022 10506 623
23011 Kennebec County, Maine B15003_022 17349 984
23013 Knox County, Maine B15003_022 7721 560
23015 Lincoln County, Maine B15003_022 6676 475
23017 Oxford County, Maine B15003_022 6574 491
23019 Penobscot County, Maine B15003_022 20953 1219
23021 Piscataquis County, Maine B15003_022 2109 285
23023 Sagadahoc County, Maine B15003_022 6784 576
23025 Somerset County, Maine B15003_022 5488 525
23027 Waldo County, Maine B15003_022 5987 511
23029 Washington County, Maine B15003_022 3767 261
23031 York County, Maine B15003_022 35385 1392
acs_data_me |> 
  mutate(county = str_remove(NAME, " county, Maine")) |> 
  select(county, bachelors_degree_attainment = estimate) |> 
  ggplot(aes(x = bachelors_degree_attainment, y = fct_reorder(county, bachelors_degree_attainment))) + 
  geom_col() +
  scale_x_continuous(labels = scales::comma) +
  labs(
    title = "Bachelor's Degree Attainment for Every County in Maine",
    x = "County",
    y = "Bachelor's Degree Attainment"
  ) +
  theme_minimal()

Submission

To submit your assignment:

  • Change the author name to your name in the YAML portion at the top of this document
  • Render your document to html and publish it to RPubs.
  • Submit the link to your Rpubs document in the Brightspace comments section for this assignment.
  • Click on the “Add a File” button and upload your .qmd file for this assignment to Brightspace.

Grading Rubric

Item
(percent overall)
100% - flawless 67% - minor issues 33% - moderate issues 0% - major issues or not attempted
Chart or table accuracy.
(45%)
No errors, good labels, everything is clearly visible in the rendered document.
At least two valid variables used from US census data (can be census or ACS)
(40%)
Messages and/or errors suppressed from rendered document and all code is shown.
(7%)
Submitted properly to Brightspace
(8%)
NA NA You must submit according to instructions to receive any credit for this portion.