Im reading in spatial data from a shapefile that contains the location of 100 districts in a province. In another dataframe, I have each districts population data.
Im trying to use ggplot to create a map of the province (from the shapefile) and color each district based on population size. The issue here is that I don't know how to fill the map garnered by the shapefile with colors based on the districts corresponding population values that are contained in another dataframe.
Note that I understand the code below doesn't work but it illustrates what Im intuitively trying to accomplish
districts_from_shapefile <- readOGR("districts.shp")
districts_with_pop <- read.csv(file = "districts_populations.csv")
ggplot() +
geom_polygon(data=districts_from_shapefile, aes(x=long,y=lat,group=group)) +
geom_polygon(data=districts_with_pop, aes(fill=districts_with_pop$population))
Thanks!