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")]

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.



danmalter/census documentation built on May 28, 2019, 7:51 p.m.