This assignment is based on some of the basic methods presented in the Datacamp course on census data.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3 v purrr 0.3.4
## v tibble 3.0.6 v dplyr 1.0.4
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(tidycensus)
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
From the ACS questionnaire identify a topic that interests you. Copy the text of the question that produces the data you want and paste it here.
Question 34 LAST WEEK, what time did this person’s trip to work usually begin?
Do a keyword search to find relevant variables in ACS5. Note that you can’t have View() in a knitted document. Use head() instead.
# Place your code here.
v19_5 = load_variables(year = 2019,"acs5",
cache = TRUE)
v19_5 %>%
filter(str_detect(str_to_lower(label),"travel time to work")) %>%
head()
Use get_acs() to obtain the values of your selected variable from the 2015-2019 file.
# Place your code here.
leave5_529 <- get_acs(geography = "county", state = "WA", variables = "B08133_003", geometry=TRUE)
## Getting data from the 2015-2019 5-year ACS
## Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
leave5_529 = leave5_529 %>%
mutate(NAME = str_replace(NAME," County, Washington",""))
Do a dotplot of the variable you selected.
# Place your code here.
ggplot(leave5_529, aes(x=reorder(NAME, estimate), y=estimate)) + geom_point() + labs(x="County", y="Count", title = "Number of People Leaving for Work between 5:00AM - 5:29AM") + coord_flip()
## Warning: Removed 1 rows containing missing values (geom_point).
Create a map for your variable using geom_sf()
# Place your code here.
ggplot(leave5_529) +
geom_sf(aes(fill = estimate)) +
geom_sf_label(aes(label = NAME))
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data