get_census_data: Multilevel Census data download function.

Description Usage Arguments Value Examples

Description

get_census_data returns county-, tract-, and block-level Census data for specified state(s). Using this function to download Census data in advance can save considerable time when running predict_race and census_helper.

Usage

1
2
get_census_data(key, states, age = FALSE, sex = FALSE,
  census.geo = "block", retry = 0)

Arguments

key

A required character object containing a valid Census API key, which can be requested here.

states

which states to extract Census data for, e.g., c("NJ", "NY").

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).

census.geo

An optional character vector specifying what level of geography to use to merge in U.S. Census 2010 geographic data. Currently "county", "tract", "block", and "place" are supported.

retry

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

Value

Output will be an object of class list indexed by state. Output will contain a subset of the following elements: state, age, sex, county, tract, block, and place.

Examples

1
## Not run: get_census_data(key = "...", states = c("NJ", "NY"), age = TRUE, sex = FALSE)

Example output



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