US Census API function

Description

Allows the user to access all Summary File 1 (SF1; 100-percent data; http://www.census.gov/prod/cen2010/doc/sf1.pdf) and American Community Survey (ACS; economic data). Requires the user to sign up for US Census API key, see http://api.census.gov/data/key_signup.html.

Usage

1
2
3
CensusAPI2010Spatial(variables, state.fips, 
level = c("county","tract","block group","block","cdp","congressional_district"), 
key, summaryfile = c("sf1", "ACS"), sp.object = NULL)

Arguments

variables

This takes a character vector of SF1 IDs or ACS IDs, see http://www.census.gov/prod/cen2010/doc/sf1.pdf for SF1 and http://www.census.gov/programs-surveys/acs/ for ACS variables.

state.fips

State fips for desired demographic variables.

level

Takes "county", "tract", "block group", "block", or "cdp"

key

User provided key (see http://api.census.gov/data/key_signup.html)

summaryfile

"sf1" or "ACS"

sp.object

sp object

Details

Add API Details.

Value

data.frame object.

Author(s)

Zack W. Almquist (almquist@umn.edu), Scott Chase (chase245@umn.edu)

References

http://api.census.gov/

Zack W. Almquist (2010). US Census Spatial and Demographic Data in R: The UScensus2000 Suite of Packages. Journal of Statistical Software, 37(6), 1-31. http://www.jstatsoft.org/v37/i06/.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 

key="YOUR KEY HERE"
sf1variables<-c("P0010001","P0030002",
"P0030003","P0030004","P0030005")
acsvariables<-c("B00001_001E",
"B01001_002E","B01001_026E","B06009_005E",
"B06009_005E","B19083_001E","B06011_002E")
#men, women, # bachelors deg, grad or prof deg, gini index, median income
test<-CensusAPI2010Spatial(sf1variables,state.fips="27",
level="tract",key,summaryfile="sf1")
test2<-CensusAPI2010Spatial(sf1variables,
state.fips=c("23","27"),level="county",key,summaryfile="sf1")



## End(Not run)