Using getCensus

Below we will collect census data for the US cities of Chicago and New York. Our radius will be the boundary around the coordinates of the city and the getCensus function will output the census data for each city within the given boundary.

library(census)

# City level data for Chicago and New York
radius <- 5
cities <- c("Chicago, IL", "New York")
df <- getCensus(cities, radius)
df[1:2, c("sitename","radius","TotPop","pctMales","pctFemales","AvgFamInc","pctPrivWageWorkers","pctGovWorkers", "pctMarried","pctBachelors","MedianHValue")]
##   sitename radius    TotPop pctMales pctFemales AvgFamInc
## 1  Chicago      5   756,255     49.3       50.7  $124,825
## 2 New York      5 2,269,840     48.6       51.4  $136,510
##   pctPrivWageWorkers pctGovWorkers pctMarried pctBachelors MedianHValue
## 1               86.0           9.5       31.9         31.1     $365,867
## 2               83.3           9.4       35.9         29.8     $782,702

Note that fields like AvgFamInc and MedianHValue are by default characters with commas. These fields need to be properly converted into numeric values if further analysis is going to be done.

Additional resources

Disclaimer

This product uses the Google Maps API and collects data from the Missouri Census Data Center, but is not endorsed or certified by Google or the Missouri Census Data Center.