# NOT RUN {
# Compute correlation between a census tract's median income and number of cafes of
# each type after removing two cases where median_income is missing
library(dplyr)
DD_vs_SB %>%
mutate(shops_per_1000 = 1000 * shops/population) %>%
filter(!is.na(median_income)) %>%
group_by(shop_type) %>%
summarize(cor = cor(median_income, shops_per_1000))
# }
Run the code above in your browser using DataLab