Title: | Collect Data from the Census API |
---|---|
Description: | Use the US Census API to collect summary data tables for SF1 and ACS datasets at arbitrary geographies. |
Authors: | Greg Macfarlane [cre, aut], Josie Kressner [aut] |
Maintainer: | Greg Macfarlane <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.4 |
Built: | 2024-11-13 05:29:48 UTC |
Source: | https://github.com/transportfoundry/censusr |
Aggregated margin of error across multiple geographies
aggregate_moe(x)
aggregate_moe(x)
x |
A numeric vector containing margins of error for estimates in multiple geographies. |
Applies a root sum of squared errors. See page A-14 of this guide: https://www.census.gov/library/publications/2009/acs/researchers.html
The aggregated margin of error for the geographies.
Josie Kressner
x <- c(3, 5, 12, 4) aggregate_moe(x) data_frame(x = x, group = c(1, 1, 2, 2)) %>% group_by(group) %>% summarise(moe = aggregate_moe(x))
x <- c(3, 5, 12, 4) aggregate_moe(x) data_frame(x = x, group = c(1, 1, 2, 2)) %>% group_by(group) %>% summarise(moe = aggregate_moe(x))
Returns GEOID for 2010 geographies.
append_geoid(address, geoid_type = "bl")
append_geoid(address, geoid_type = "bl")
address |
A tibble/data frame with (at a minimum, others can be present) either character columns street, city, and state OR numeric columns lat and lon. Lat/lon columns take priority. |
geoid_type |
GEOID level to return, |
It is possible in some situations for the geolocator API to return a 500 error. Repeating the call should avoid this.
the original tibble with GEOIDs appended as a new column called
geoid
.
## Not run: airports <- dplyr::data_frame( street = "700 Catalina Dr", city = "Daytona Beach", state = "FL" ) append_geoid(airports, 'tr') ## End(Not run)
## Not run: airports <- dplyr::data_frame( street = "700 Catalina Dr", city = "Daytona Beach", state = "FL" ) append_geoid(airports, 'tr') ## End(Not run)
This is an internal function and is not intended for users. See instead call_census_api.
call_api_once(variables_to_get, geoid, allgeos, data_source, year, period, api_key)
call_api_once(variables_to_get, geoid, allgeos, data_source, year, period, api_key)
variables_to_get |
A character vector of the desired variable names for the Census API call, defined at https://www.census.gov/data/developers/data-sets.html |
geoid |
A character string with a FIPS code, between 2 and 15 digits long. |
allgeos |
(optional) A string identifying the type of geography for
which to collect data within the the requested |
data_source |
A string identifying whether the SF1 (decennial census) or ACS data is desired. |
year |
If |
period |
If |
api_key |
The user's Census API key (as a character string). You can get
a free key from [Census](http://api.census.gov/data/key_signup.html). See
|
A codedata.frame with the requested variables at the requested geography.
Returns Census data for the 2010 SF1 or ACS 2013-2015 1-, 3-, and 5-Yr aggregations for requested variables and geographies.
call_census_api(variables_to_get, names = NULL, geoids, allgeos = NULL, data_source = c("sf1", "acs"), year = 2013, period = 5, api_key = NULL)
call_census_api(variables_to_get, names = NULL, geoids, allgeos = NULL, data_source = c("sf1", "acs"), year = 2013, period = 5, api_key = NULL)
variables_to_get |
A character vector of the desired variable names for the Census API call, defined at https://www.census.gov/data/developers/data-sets.html |
names |
A character vector of the same length as |
geoids |
A character vector of FIPS codes; must be at least to the county (5-digit) level, and can accept down to blocks (15-digit). |
allgeos |
(optional) A string identifying the type of geography for
which to collect data within the the requested |
data_source |
A string identifying whether the SF1 (decennial census) or ACS data is desired. |
year |
If |
period |
If |
api_key |
The user's Census API key (as a character string). You can get
a free key from [Census](http://api.census.gov/data/key_signup.html). See
|
See vignette('censusr', package = 'censusr')
for examples.
a data_frame with each requested variable at each requested geography.
Call gelocator for one address
call_geolocator(street, city, state)
call_geolocator(street, city, state)
street |
A character string indicating a street name and number |
city |
A character string indicating a city |
state |
A two-digit character string with a state postal code |
A character string representing the Census block of the supplied address.
importFrom utils URLencode importFrom httr GET stop_for_status
Call gelocator for one address with lat/lon
call_geolocator_latlon(lat, lon)
call_geolocator_latlon(lat, lon)
lat |
A numeric value |
lon |
A numeric value |
A character string representing the Census block of the supplied lat/lon.
importFrom utils URLencode importFrom httr GET stop_for_status
The censusr package provides principally one main function: call_census_api allows users to pass a list of variables and a list of geographies, and returns a data_frame with the requested data.
Construct a geography request string from a FIPS Code
get_geo_url(geoid, allgeos)
get_geo_url(geoid, allgeos)
geoid |
A character string with a FIPS code, between 2 and 15 digits long. |
allgeos |
(optional) A string identifying the type of geography for
which to collect data within the the requested |
A string with the FIPS formatted for an API request.