census_geo_api: Census Data download function.

Description Usage Arguments Details Value References Examples

Description

census_geo_api retrieves U.S. Census geographic data for a given state.

Usage

1
2
census_geo_api(key, state, geo = "tract", age = FALSE, sex = FALSE,
  retry = 0)

Arguments

key

A required character object. Must contain user's Census API key, which can be requested here.

state

A required character object specifying which state to extract Census data for, e.g., "NJ".

geo

A character object specifying what aggregation level to use. Use "county", "tract", "block", or "place". Default is "tract". Warning: extracting block-level data takes very long.

age

A TRUE/FALSE object indicating whether to condition on age or not. If FALSE (default), function will return Pr(Geolocation | Race). If TRUE, function will return Pr(Geolocation, Age | Race). If sex is also TRUE, function will return Pr(Geolocation, Age, Sex | Race).

sex

A TRUE/FALSE object indicating whether to condition on sex or not. If FALSE (default), function will return Pr(Geolocation | Race). If TRUE, function will return Pr(Geolocation, Sex | Race). If age is also TRUE, function will return Pr(Geolocation, Age, Sex | Race).

retry

The number of retries at the census website if network interruption occurs.

Details

This function allows users to download U.S. Census 2010 geographic data, at either the county, tract, block, or place level, for a particular state.

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 geographic data.

References

Relies on get_census_api, get_census_api_2, and vec_to_chunk functions authored by Nicholas Nagle, available here.

Examples

1
2
## Not run: census_geo_api(key = "...", states = c("NJ", "DE"), geo = "block")
## Not run: census_geo_api(key = "...", states = "FL", geo = "tract", age = TRUE, sex = TRUE)

wru documentation built on May 2, 2019, 7:03 a.m.