Tim Thoughts data/rstats/policy

American Census Survey in R with CartoDB

honors to Kyle Walker per usual, for his handy hack of the ACS package.

Orange County’s GINI index as of the American Census Survey’s recent 2010-2014 estimates.

library(dplyr)
library(acs14lite)
library(CartoDB)
library(rgdal)
library(acs)

Set up permissions (get API keys from ACS, CartoDB)

set_api_key('zzzzzz')
cartodb('username','apikey')

Code

acs.lookup(endyear=2014, keyword="Gini") #use ACS package to look up correct table numbers
oc<- acs14(geography = 'tract', variable = c('B19083_001E', 'B19083_001M'), state = 'CA', county='Orange')
oc_tracts <- tracts('CA', 'Orange County', cb = TRUE)
oc2<- oc %>% mutate(geoid = paste0(state, county, tract), gini = round(100 *(B19083_001E),1), moe= round(100 *(B19083_001M),1)) %>% select (geoid, gini, moe)
oc_tracts2 <- geo_join(oc_tracts, oc2, "GEOID", "geoid")
r2cartodb(oc_tracts2, 'oc')

No big surprise, Newport Beach’s pretty wealthy. Digging deeper in ACS data with CartoDB sounds promising though, it’s a lot easier to visualize disparities.

comments powered by Disqus