runCensusAPIQueries: Census API function

Description Usage Arguments Details See Also Examples

View source: R/census_API_functions.R

Description

Query data from US Census Bureau API and collect result into dplyr data frame

Usage

1
runCensusAPIQueries(data_url, key, vars, region, numeric = TRUE)

Arguments

data_url

The url root of the api including the '?'

key

API key

vars

A character vector of variable names

region

A region specification containing a 'for:' and possibly an 'in:'

Details

For information on the US Census API see https://www.census.gov/developers/.

This function is a modified version of the code published here: http://rstudio-pubs-static.s3.amazonaws.com/19337_2e7f827190514c569ea136db788ce850.html

See Also

Other census functions: queryCensusAPI, statePop, vecToChunk

Examples

1
2
3
4
5
6
runCensusAPIQueries(
  data_url = "https://api.census.gov/data/2017/acs/acs5?",
  key = rstudioapi::askForSecret("censusKey"),
  vars = paste0("B01001_", str_pad(2:49, 3, pad = "0"), "E"),
  region = "for=county:*&in=state:31"
)

natbprice/huntfishapp documentation built on Sept. 2, 2020, 11:01 p.m.