Learn R Programming

wru (version 0.1-1)

censusData: Census Data download function.

Description

censusData retrieve Census data.

Usage

censusData(key, state, geo = "tract", demo = FALSE)

Arguments

key
A required character object. Must contain user's Census API key, which can be requested here.
state
to extract Census data for, e.g. "NJ".
geo
A character object specifying what aggregation level to use. Use "county", "tract", or "block". Default is "tract". Warning: extracting block-level data takes very long.
demo
A TRUE/FALSE object indicating whether to condition on demographics (i.e., age and sex) or not. If TRUE, function will return Pr(Geolocation, Age, Sex | Race). If FALSE, function wil return Pr(Geolocation | Race). Default is FALSE.

Value

Output will be an object of class list, indexed by state names. It will consist of the original user-input data with additional columns of Census data.

Details

This function allows users to download (e.g., voter file) the U.S. Census 2010 data, at either county level, tract level or block level.

References

Relies on getCensusApi, getCensusApi2, and vecToChunk functions authored by Nicholas Nagle, available here.

Examples

Run this code

## Not run: censusData(key = "...", states = c("NJ", "DE"), geo = "block")
## Not run: censusData(key = "...", states = "FL", geo = "tract", 
# demo = TRUE)## End(Not run)

Run the code above in your browser using DataLab