boston_blocks20 <- boston_blocks20 %>% filter(total > 0)
boston_blocks10 <- boston_blocks10 %>% filter(total > 0)
boston_blocks00 <- boston_blocks00 %>% filter(total > 0)
ggplot() + geom_sf(data = boston_blocks20,aes(fill=black/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
ggtitle("Black Population 2020")+
scale_fill_continuous(limits = c(0, 1))
ggplot() + geom_sf(data = boston_blocks10,aes(fill=black/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Black Population 2010")
ggplot() + geom_sf(data = boston_blocks00,aes(fill=black/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Black Population 2000")
ggplot() + geom_sf(data = boston_blocks20,aes(fill=white/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("White Population 2020")
ggplot() + geom_sf(data = boston_blocks10,aes(fill=white/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("White Population 2010")
ggplot() + geom_sf(data = boston_blocks00,aes(fill=white/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("White Population 2000")
ggplot() + geom_sf(data = boston_blocks20,aes(fill=hispanic/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Hispanic Population 2020")
ggplot() + geom_sf(data = boston_blocks10,aes(fill=hispanic/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Hispanic Population 2010")
ggplot() + geom_sf(data = boston_blocks00,aes(fill=hispanic/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Hispanic Population 2000")
ggplot() + geom_sf(data = boston_tracts20,aes(fill=black/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Black Population 2020")
ggplot() + geom_sf(data = boston_tracts10,aes(fill=black/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Black Population 2010")
ggplot() + geom_sf(data = boston_tracts00,aes(fill=black/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Black Population 2000")
ggplot() + geom_sf(data = boston_tracts20,aes(fill=white/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("White Population 2020")
ggplot() + geom_sf(data = boston_tracts10,aes(fill=white/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("White Population 2010")
ggplot() + geom_sf(data = boston_tracts00,aes(fill=white/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("White Population 2000")
ggplot() + geom_sf(data = boston_tracts20,aes(fill=hispanic/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Hispanic Population 2020")
ggplot() + geom_sf(data = boston_tracts10,aes(fill=hispanic/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Hispanic Population 2010")
ggplot() + geom_sf(data = boston_tracts00,aes(fill=hispanic/total),color=NA) + geom_sf(data = planning_districts, color="yellow",fill = NA)+theme_map()+
scale_fill_continuous(limits = c(0, 1))+
ggtitle("Hispanic Population 2000")
#comparison between neighborhoods
neighborhoods <- read_csv("C:/Users/liste/OneDrive - Harvard University/Studio/Assignment C/neighborhoods.csv")
## Rows: 3542 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Neighborhood, Variable, Value
## dbl (2): Year, PCT
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
neighborhoods$Value <- as.double(neighborhoods$Value)
## Warning: NAs introduced by coercion
black <- neighborhoods %>% filter(Variable == "Black/ African American") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% Black")
ggplotly(black)
white <- neighborhoods %>% filter(Variable == "White") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% White")
ggplotly(white)
hispanic <- neighborhoods %>% filter(Variable == "Hispanic") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% Hispanic")
ggplotly(hispanic)
renter <- neighborhoods %>% filter(Variable == "Owner-occupied") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% Owner-Occupied")
ggplotly(renter)
foreign <- neighborhoods %>% filter(Variable == "Foreign Born") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% Foreign-born")
ggplotly(foreign)
bachelors <- neighborhoods %>% filter(Variable == "Bachelor's Degree or Higher") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% Bachelors")
ggplotly(bachelors)
female <- neighborhoods %>% filter(Variable == "Female") %>%
ggplot(aes(Year,PCT,color=Neighborhood))+geom_line()+geom_point()+
labs(title="% Female Workforce")
ggplotly(female)
stackedbar <- neighborhoods %>% filter(Variable == "Population") %>%
ggplot(aes(Year,Value,fill=Neighborhood))+geom_bar(stat = "identity")
ggplotly(stackedbar)
## Warning: Removed 1 rows containing missing values (position_stack).
##City comparison
v20 <- load_variables(2020, "acs5", cache = TRUE)
acs_vars <- c(
pop = "B03002_001",
white ="B03002_003",
black = "B03002_004",
asian = "B03002_006",
other = "B03002_008",
mixed = "B03002_009",
hispanic = "B03002_012",
income = "B19013_001",
income_white = "B19013A_001",
income_black = "B19013B_001",
income_hispanic = "B19013I_001",
value = "B25077_001",
rent_income = "B25071_001",
less_than_hs = "B06009_002",
hs = "B06009_003",
some_college= "B06009_004",
bachelors= "B06009_005",
grad = "B06009_006"
)
acs_vars_ancestry <- c(
pop = "B03002_001",
english = "B06007_003",
spanish = "B06007_002",
spanish_english_not_well = "B06007_005",
other_language = "B06007_006",
foreign_born = "B05002_013",
west_indian = "B04006_094",
haitian = "B04006_101",
ssafrica = "B04006_073",
capeverde = "B04006_074",
ethiopia = "B04006_075",
ghanian = "B04006_077",
nigerian = "B04006_079",
somalia = "B04006_082",
mexican = "B03001_004",
boricua = "B03001_005",
dominican = "B03001_007",
central="B03001_008"
)
boston <- "2507000"
gateway <- c(
"2553960",
"2530840",
"2567000",
"2523875",
"2582000",
"2537000",
"2529405",
"2534550",
"2509000",
"2523000",
"2545000",
"2502690",
"2503690",
"2513205",
"2513660",
"2521990",
"2535075",
"2537490",
"2537875",
"2540710",
"2552490",
"2555745",
"2556585",
"2559105",
"2569170",
"2576030"
)
ma_place <- get_acs(year = 2020, geography = "place",state = "MA", variables = acs_vars,output = "wide")
## Getting data from the 2016-2020 5-year ACS
ma_ancestry_place <- get_acs(year = 2020, geography = "place",state = "MA", variables = acs_vars_ancestry,output = "wide")
## Getting data from the 2016-2020 5-year ACS
gateway_places <- ma_place %>% left_join(ma_ancestry_place) %>% filter(GEOID %in% gateway | GEOID == "2507000") %>%
mutate(NAME=str_remove(NAME," city, Massachusetts")) %>%
mutate(geography="City")
## Joining, by = c("GEOID", "NAME", "popE", "popM")
ma <- get_acs(year = 2020, geography = "state",state = "MA", variables = acs_vars,output = "wide")
## Getting data from the 2016-2020 5-year ACS
ma_ancestry <- get_acs(year = 2020, geography = "state",state = "MA", variables = acs_vars_ancestry,output = "wide")
## Getting data from the 2016-2020 5-year ACS
ma %>% left_join(ma_ancestry) %>%
mutate(geography="State")-> ma
## Joining, by = c("GEOID", "NAME", "popE", "popM")
boston_tract <- get_acs(year = 2020, geography = "tract",state = "MA",county = "Suffolk", variables = acs_vars,output = "wide")
## Getting data from the 2016-2020 5-year ACS
boston_ancestry <- get_acs(year = 2020, geography = "tract",state = "MA",county = "Suffolk", variables = acs_vars_ancestry,output = "wide")
## Getting data from the 2016-2020 5-year ACS
boston_nhood <- get_acs(year = 2020, geography = "tract",county = "Suffolk",state = "MA", variables = acs_vars,output = "wide")
## Getting data from the 2016-2020 5-year ACS
boston_nhood_ancestry <- get_acs(year = 2020, geography = "tract",state = "MA",county = "Suffolk", variables = acs_vars_ancestry,output = "wide")
## Getting data from the 2016-2020 5-year ACS
boston_nhood %>% left_join(boston_nhood_ancestry) %>% left_join(xwalk,by = c("GEOID"="GEOID10")) %>%
filter(!is.na(Neighborho))-> boston_nhood_join
## Joining, by = c("GEOID", "NAME", "popE", "popM")
boston_nhood_join %>% st_drop_geometry() %>% group_by(Neighborho) %>% summarise(
popE =sum(popE),
whiteE=sum(whiteE),
blackE=sum(blackE),
asianE=sum(asianE),
otherE=sum(otherE),
mixedE=sum(mixedE),
hispanicE=sum(hispanicE)) %>% rename(NAME=Neighborho) %>%
mutate(geography="Neighborhood")-> boston_nhood_join
data_cities <- bind_rows(ma,gateway_places,boston_nhood_join)
##gatewaygraphs
hisp_black <- ggplot(data = data_cities,aes(shape=geography,x=blackE/popE,y=hispanicE/popE,color=NAME))+geom_point()+geom_hline(yintercept = 0.12)+geom_vline(xintercept =0.0678)
ggplotly(hisp_black)
## Warning: `gather_()` was deprecated in tidyr 1.2.0.
## Please use `gather()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.