Description Usage Arguments Details Value References Examples
getCensusApi
obtains U.S. Census data via the public API.
1 | getCensusApi(data_url, key, vars, region)
|
data_url |
URL root of the API, including the question mark,
e.g., |
key |
A required character object containing user's Census API key, which can be requested here. |
vars |
A character vector of variables to get,
e.g., |
region |
Character object specifying which region to obtain data for.
Must contain "for" and possibly "in",
e.g., |
This function obtains U.S. Census data via the public API. User can specify the variables and region(s) for which to obtain data.
If successful, output will be an object of class data.frame
.
If unsuccessful, function prints the URL query that caused the error.
Based on code authored by Nicholas Nagle, which is available here.
1 2 3 | ## Not run: getCensusApi(data_url = "http://api.census.gov/data/2010/sf1?", key = "...",
vars = c("P0050003","P0050004","P0050005", "P0050006"), region = "for=county:*&in=state:34")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.