forked from engine143/map-spring2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise-2_tidycensus.Rmd
55 lines (34 loc) · 1.46 KB
/
exercise-2_tidycensus.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
title: "Exercise 2: Choropleths with tidycensus"
---
## Load Libraries
```{r}
library(tidyverse)
library(tidycensus)
library(sf)
library(leaflet)
library(mapview)
```
## Set API key
Insert your own API Key. You may request a free key from the Census API tool https://api.census.gov/data/key_signup.html
```{r}
census_api_key("long-string-of-numbers-from-census-api-key-generator")
```
## Choose a census variable
I recommend using one of the following variables. However, you can use the `tidycensus::load_variables()` and follow the "Searching for variables" [instructions](https://walkerke.github.io/tidycensus/articles/basic-usage.html#searching-for-variables).
- `B19013_001` - median household income
- `B08131_001` - AGGREGATE TRAVEL TIME TO WORK (IN MINUTES) OF WORKERS BY PLACE OF WORK--STATE AND COUNTY LEVEL: Worked in State of residence: Workers 16 years and over who did not work at home -- (Estimate)
- `B08103_001` - MEDIAN AGE BY MEANS OF TRANSPORTATION TO WORK: Total: Taxicab, motorcycle, bicycle, or other means: Workers 16 years and over -- (Estimate)
## get_acs()
Load the variable and assign and object name for some USA county using the `get_acs` function.
```{r}
census_variable <-
get_acs(geography = "",
variables = "",
state = "",
geometry = TRUE)
```
## Make choropleth
Make choropleth via `mapview` by filling county polygons (census geography) with correlated value (from the ACS)
```{r make_choropleth}
```