getCensusApi2: Census API URL assembler.

Description Usage Arguments Details Value References Examples

View source: R/getCensusApi2.R

Description

getCensusApi2 assembles URL components for getCensusApi.

Usage

1
getCensusApi2(data_url, key, get, region)

Arguments

data_url

URL root of the API, including the question mark, e.g., "http://api.census.gov/data/2010/sf1?".

key

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

get

A character vector of variables to get, e.g., c("P0050003","P0050004","P0050005", "P0050006"). If there are more than 50 variables, then function will automatically split variables into separate queries.

region

Character object specifying which region to obtain data for. Must contain "for" and possibly "in", e.g., "for=block:1213&in=state:47+county:015+tract:*".

Details

This function assembles the URL components and sends the request to the Census server. It is used by the getCensusApi function. The user should not need to call this function directly.

Value

If successful, output will be an object of class data.frame. If unsuccessful, function prints the URL query that was constructed.

References

Based on code authored by Nicholas Nagle, which is available here.

Examples

1
2
3
## Not run: getCensusApi2(data_url = "http://api.census.gov/data/2010/sf1?", key = "...",
get = c("P0050003","P0050004","P0050005", "P0050006"), region = "for=county:*&in=state:34")
## End(Not run)

HJ08003/HJwru documentation built on May 6, 2019, 9:47 p.m.