library(tidyverse)
library(tidycensus)Warning: package 'tidycensus' was built under R version 4.4.3
library(gapminder)
library(gt)
library(gtExtras)Warning: package 'gtExtras' was built under R version 4.4.3
library(scales)Open the assign06.qmd file and complete the exercises.
This is a very open-ended assignment. There are three musts:
You must use the tidycensus package 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
library(tidyverse)
library(tidycensus)Warning: package 'tidycensus' was built under R version 4.4.3
library(gapminder)
library(gt)
library(gtExtras)Warning: package 'gtExtras' was built under R version 4.4.3
library(scales)This is your work area. Add as many code cells as you need.
library(tidycensus)
census_api_key("711ff3a0967f49c5ba44a4b23b1c8f196f399abc", install = TRUE, overwrite = TRUE)Your original .Renviron will be backed up and stored in your R HOME directory if needed.
Your API key has been stored in your .Renviron and can be accessed by Sys.getenv("CENSUS_API_KEY").
To use now, restart R or run `readRenviron("~/.Renviron")`
[1] "711ff3a0967f49c5ba44a4b23b1c8f196f399abc"
readRenviron("~/.Renviron")FL_income_2022 <- get_acs(
geography = "county",
variables = "B19013_001",
state = "FL",
year = 2022
)Getting data from the 2018-2022 5-year ACS
FL_college_2022 <- get_acs(
geography = "county",
variables = "B20004_004",
state = "FL",
year = 2022
)Getting data from the 2018-2022 5-year ACS
library(ggrepel)
# Combine the two tibbles
FL_combined_2022 <- left_join(FL_income_2022, FL_college_2022, by = c("GEOID", "NAME")) |>
select(NAME, estimate.x, estimate.y) |>
rename('County, Florida' = NAME, 'Income' = estimate.x, 'Some College Degree' = estimate.y
) |>
filter(Income >= 80000) |>
ggplot(aes(x = `Income`, y = `Some College Degree`)) +
geom_label_repel(aes(label = `County, Florida`), color="blue") +
geom_point() +
labs(title = "Income of over $80,000 vs. Population with College Degree in FL Counties",
x = "Median Household Income",
y = "Total of People with Some College Degree") +
theme_minimal()
print(FL_combined_2022)To submit your assignment:
| 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. |