knitr::opts_chunk$set(echo = TRUE) knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) library(tidyverse) library(data.table) library(tigris) library(mapview)
sf_pop <- readRDS("data/processed/SF_agents_processed.rds") table(sf_pop$hhsize) table(sf_pop$hhincome) table(sf_pop$sex) table(sf_pop$age) table(sf_pop$occp) table(sf_pop$race) # SF_cts <- tigris::tracts("06", "075", year = 2018, class = "sf") SF_cts <- readRDS("data/processed/SF_cts_sf.rds") load("data/get/got/CA_SF_data2021-02-01.Rdata")
sf_pop_sum <- sf_pop %>% group_by(geoid) %>% summarise(Pop = n()) SF_pop_cts <- SF_cts %>% left_join(sf_pop_sum, by = c("GEOID" = "geoid")) mapview::mapview(SF_pop_cts, zcol = "Pop")
sf_pct_white <- sf_pop %>% group_by(geoid) %>% summarise(Pop = n(), White = sum(race == 1), pct_wht = White/Pop) SF_pct_wht_cts <- SF_cts %>% left_join(sf_pct_white, by = c("GEOID" = "geoid")) mapview::mapview(SF_pct_wht_cts, zcol = "pct_wht")
sf_pct_hisp <- sf_pop %>% group_by(geoid) %>% summarise(Pop = n(), Hisp = sum(race == 8), pct_hisp = Hisp/Pop) SF_pct_hisp_cts <- SF_cts %>% left_join(sf_pct_hisp, by = c("GEOID" = "geoid")) mapview::mapview(SF_pct_hisp_cts, zcol = "pct_hisp")
sf_pct_black <- sf_pop %>% group_by(geoid) %>% summarise(Pop = n(), Black = sum(race == 2), pct_black = Black/Pop) SF_pct_black_cts <- SF_cts %>% left_join(sf_pct_black, by = c("GEOID" = "geoid")) mapview::mapview(SF_pct_black_cts, zcol = "pct_black")
sf_income <- sf_pop %>% group_by(geoid) %>% summarise(Mean_Income = mean(hhincome)) SF_income_cts <- SF_cts %>% left_join(sf_income, by = c("GEOID" = "geoid")) mapview::mapview(SF_income_cts, zcol = "Mean_Income")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.