Every year, the US Census Bureau releases new estimates of the population of every metropolitan area, county, city and town in the US. They are estimates because they only do the headcount census every 10 years. Between then, they use data and modeling to estimate what the population is.
In [4]:
library(dplyr)
library(ggplot2)
In [1]:
counties <- read.csv(url("https://www2.census.gov/programs-surveys/popest/datasets/2010-2017/counties/totals/co-est2017-alldata.csv"))
In [2]:
head(counties)
In [3]:
colnames(counties)
In [11]:
nebraska <- counties %>% filter(STNAME == "Nebraska") %>% filter(SUMLEV == 50) %>% mutate(change = ((POPESTIMATE2017-POPESTIMATE2016)/POPESTIMATE2016)*100, pos = change >0)
In [15]:
nebraskasorted <- arrange(nebraska, desc(change)) %>% mutate(CTYNAME = factor(CTYNAME, CTYNAME))
In [16]:
ggplot(nebraskasorted, aes(x=CTYNAME, y=change, fill=pos)) + geom_bar(stat='identity', position='identity') + coord_flip()
In [ ]: