Skip to content

Instantly share code, notes, and snippets.

@zmughal
Created November 21, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zmughal/1c2a4e0ff4502b32135b4b82760a4b25 to your computer and use it in GitHub Desktop.
Save zmughal/1c2a4e0ff4502b32135b4b82760a4b25 to your computer and use it in GitHub Desktop.
library(magrittr)
# http://www.census.gov/popest/data/counties/totals/2015/files/CO-EST2015-alldata.csv
data <- read.csv('CO-EST2015-alldata.csv')
data %>%
subset( SUMLEV == 50 ) %>%
.[c('STATE', 'STNAME', 'COUNTY')] %>%
aggregate( . ~ STATE + STNAME, data = . , FUN = . %>% unique %>% length ) %>%
.[which.max(.$COUNTY), ] %>%
print
#head %>%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment