-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLA558_assignment3_Demo.R
51 lines (40 loc) · 1.74 KB
/
LA558_assignment3_Demo.R
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
## ----install-packages---------------------------------------------
install.packages(c("tidycensus", "tidyverse", "tigris", "sf"))
library(tidycensus)
library(tigris)
library(tidyverse)
library(sf)
options(tigris_use_cache = TRUE)
census_api_key('', overwrite=TRUE)
#The following example shows median household income from the
#2015-2019 ACS for Census tracts in Boone County, Iowa
IowaMedianIncome <- get_acs(state = "IA",
geography = "county",
variables = "B19013_001",
geometry = TRUE)
head(IowaMedianIncome)
st_write(IowaMedianIncome,"IowaMedianIncome.geojson")
#Same as above but no Geometry
IowaMedianIncome <- get_acs(state = "IA",
geography = "county",
variables = "B19013_001",
geometry = FALSE)
head(IowaMedianIncome)
write.csv(IowaMedianIncome,"IowaMedianIncome.csv")
#The following example shows median household income from the
#2015-2019 ACS for Townships in Boone County, Iowa
BooneMedianIncome <- get_acs(state = "IA",
county = "Boone",
geography = "county subdivision",
variables = "B19013_001",
geometry = TRUE)
head(BooneMedianIncome)
st_write(BooneMedianIncome,"BooneMedianIncome.geojson")
#Same as above but no Geometry
BooneMedianIncome <- get_acs(state = "IA",
county = "Boone",
geography = "county subdivision",
variables = "B19013_001",
geometry = FALSE)
head(BooneMedianIncome)
write.csv(BooneMedianIncome,"BooneMedianIncome.csv")