library(ggplot2)
library(dplyr)
# Sum cases & population for each county
lung_cancer_rate <- pennLC_sf %>%
group_by(county) %>%
summarize(cases = sum(cases), population = sum(population)) %>%
mutate(rate = cases/population)
# Static map of Pennsylvania lung cancer rates for each county
if (FALSE) {
ggplot() +
geom_sf(data = lung_cancer_rate, aes(fill = rate))
}
Run the code above in your browser using DataLab