View source: R/get_census_api_2.R
get_census_api_2 | R Documentation |
get_census_api_2
assembles URL components for get_census_api
.
get_census_api_2(
data_url,
key = Sys.getenv("CENSUS_API_KEY"),
get,
region,
retry = 3
)
data_url |
URL root of the API,
e.g., |
key |
A character string containing a valid Census API key, which can be requested from the U.S. Census API key signup page. By default, attempts to find a census key stored in an
environment variable named |
get |
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., |
retry |
The number of retries at the census website if network interruption occurs. |
This function assembles the URL components and sends the request to the Census server.
It is used by the get_census_api
function. The user should not need to call this
function directly.
If successful, output will be an object of class data.frame
.
If unsuccessful, function prints the URL query that was constructed.
Based on code authored by Nicholas Nagle, which is available here.
## Not run: try(get_census_api_2(data_url = "https://api.census.gov/data/2020/dec/pl",
get = c("P2_005N", "P2_006N", "P2_007N", "P2_008N"), 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.