library(tidyverse)
library(tidycensus)
library(gapminder)
library(gt)
library(gtExtras)
library(scales)Assignment 6
Go to the shared posit.cloud workspace for this class and open the assign06 project. Open the assign06.qmd file and complete the exercises.
This is a very open-ended assignment. There are three musts:
You must use the
tidycensuspackage to get either decennial or ACS data from the US Census Bureau.You must get data for two different variables and they can’t be population or median home values.
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
ne_income <- get_acs(geography = "state",
variables = "B19013_001",
survey = "acs1",
state = c("ME", "NH", "VT", "MA",
"RI", "CT", "NY"))Getting data from the 2022 1-year ACS
The 1-year ACS provides data for geographies with populations of 65,000 and greater.
Warning: • You have not set a Census API key. Users without a key are limited to 500
queries per day and may experience performance limitations.
ℹ For best results, get a Census API key at
http://api.census.gov/data/key_signup.html and then supply the key to the
`census_api_key()` function to use it throughout your tidycensus session.
This warning is displayed once per session.
ggplot(ne_income, aes(x = estimate, y = reorder(NAME, estimate))) +
geom_point()g_color <- ggplot(ne_income, aes(x = estimate, y = reorder(NAME, estimate))) +
geom_point(color = "maroon", size = 4)
g_scale <- g_color +
scale_x_continuous(labels = scales::dollar) +
theme_minimal(base_size = 12)
g_label <- g_scale +
labs(x ="2016 ACS estimate",
y = "",
title = "Median household income by state")
g_labelThis is your work area. Add as many code cells as you need.
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. |