-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqcarrasco_nycGeo.R
64 lines (59 loc) · 2.03 KB
/
qcarrasco_nycGeo.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
52
53
54
55
56
57
58
59
60
61
62
63
# originally from - https://github.com/mfherman/nycgeo
# installation for nycgeo - # install.packages("remotes")
# remotes::install_github("mfherman/nycgeo")
# libraries to import
library(nycgeo)
library(sf)
library(tidyverse) # accesses the Census Bureau's API
####
# this visualization creates the base map for
nyc_boundaries(geography = 'tract')
nyc_tracts <- nyc_boundaries(
geography = 'tract',
filter_by = 'borough',
region = c("brooklyn", "queens", "manhattan", "bronx", "staten island"),
add_acs_data = TRUE
)
ggplot(nyc_tracts) +
geom_sf() +
theme_minimal() +
labs(title = 'New York City: Census Tracts') #edit font and add date
# median household income
# alter sizing of the map
ggplot(nyc_tracts) +
geom_sf(aes(fill = med_hhinc_est)) +
scale_fill_viridis_c(
name = "Income Scale (Estimate)",
) +
theme_void() +
theme(panel.grid = element_line(color = 'transparent')) +
labs(title = "New York City: Median Annual Household Income Estimates")
# estimated income of NYC residents below the poverty line
# alter sizing of the map
ggplot(nyc_tracts) +
geom_sf(aes(fill = pop_inpov_pct_est)) +
scale_fill_viridis_c(
name = "Population",
) +
theme_void() +
theme(panel.grid = element_line(color = 'transparent'))+
labs(title = "Population With Income Below Poverty Line")
# median age of new yorkers
ggplot(nyc_tracts) +
geom_sf(aes(fill = med_age_est)) +
scale_fill_viridis_c(
name = 'Median Age Scale'
) +
theme_void() +
theme(panel.grid = element_line(color = 'transparent')) +
labs(title = 'Median Age of New Yorkers')
# [DEBUG] --------------------------------------------------------
#comparison of the education levels [EDIT THIS SECTION] # change fill - create separate variable levels for education
ggplot(nyc_tracts) +
geom_sf(aes(fill = pop_prof_est)) +
scale_fill_viridis_c(
name = 'Percentage of Pop. w/ a Doctorate Degree'
) +
theme_void() +
theme(panel.grid = element_line(color = 'transparent')) +
labs(title = "Population With Doctorate Degree")