Title: | A Convenient API for Accessing United States Census Bureau's Quarterly Workforce Indicator |
---|---|
Description: | The purpose of this package is to access the United States Census Bureau's Quarterly Workforce Indicator data. Additionally, the data will be retrieved in a tidy format for further manipulation with full variable descriptions added if desired. Information about the United States Census Bureau's Quarterly Workforce Indicator is available at <https://www.census.gov/data/developers/data-sets/qwi.html>. |
Authors: | Michael DeWitt [aut, cre] , Mona Ahmadiani [aut] , Adam S. Hyde [aut] |
Maintainer: | Michael DeWitt <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-10-26 04:26:17 UTC |
Source: | https://github.com/medewitt/tidyqwi |
This function add labels to a 'qwi' object
add_qwi_labels(df)
add_qwi_labels(df)
df |
an object with a class of 'qwi' |
a data.frame with formatted column names and types
library(tidyqwi) # Add labels labelled_nc <- add_qwi_labels(nc_qwi) # Check the label for the data attr(labelled_nc[["Emp"]], "label")
library(tidyqwi) # Add labels labelled_nc <- add_qwi_labels(nc_qwi) # Check the label for the data attr(labelled_nc[["Emp"]], "label")
The function verifies that API call was sucessful. If the call was not sucessful, this function passes the message received from the US Census API for further troublshooting,
check_census_api_call(call)
check_census_api_call(call)
call |
a returned call from the US Census API |
a string vector with the message from the US Census API
if(FALSE){ library(tidyqwi) library(httr) # A single call to the API without an API Key url <- "api.census.gov/data/timeseries/qwi/sa?get=Emp&for=county:198&key=NOKEY" single_call <- httr::GET(url) stop_for_status(single_call) # Because a non valid API key was specified an message will be returned check_census_api_call(single_call) }
if(FALSE){ library(tidyqwi) library(httr) # A single call to the API without an API Key url <- "api.census.gov/data/timeseries/qwi/sa?get=Emp&for=county:198&key=NOKEY" single_call <- httr::GET(url) stop_for_status(single_call) # Because a non valid API key was specified an message will be returned check_census_api_call(single_call) }
The function verifies if a valid FIPS code was passed and converts it to a unified standard for internal use.
converted_fips(fips)
converted_fips(fips)
fips |
the state abbreviation or fips code vector |
States Abbreviations or FIPs as FIP character strings
a vector with the State FIPS code
library(tidyqwi) converted_fips(37) converted_fips("37") converted_fips("NC") converted_fips("nc")
library(tidyqwi) converted_fips(37) converted_fips("37") converted_fips("NC") converted_fips("nc")
Geographic Codes
geo_codes
geo_codes
a dataframe with 5423 rows and 3 columns:
geography
label
geolevel
...
https://lehd.ces.census.gov/data/schema/latest/label_geography.csv
The purpose of this function is to retrive firm information from the US Census' Quarterly Workforce Indicator API. These data can be retrieved with by specifying the states, the quarters, the years, and additional detail. This function can accept multiple states, years and quarters. This makes the data retrieval easier and stay inside of the US Census' limits on the API.
get_qwi( years, variables = NULL, quarters = c(1, 2, 3, 4), industry_level = 2, states, endpoint = "sa", all_groups = TRUE, owner_code = TRUE, geography = "cbsa", seasonadj = "U", apikey = NULL, processing = "sequential" )
get_qwi( years, variables = NULL, quarters = c(1, 2, 3, 4), industry_level = 2, states, endpoint = "sa", all_groups = TRUE, owner_code = TRUE, geography = "cbsa", seasonadj = "U", apikey = NULL, processing = "sequential" )
years |
years to fetch (e.g. 2010, or c(2010, 2011)) |
variables |
the variables you wish to fetch. Default is all. |
quarters |
The quarters to fetch (e.g. c(1,2,3,4)) Default is all |
industry_level |
Industries to fetch. Default is all level 2 |
states |
state fips code to fetch |
endpoint |
US Census endpoint designation. One of "sa" for Sex * Age, "se" for Sex by Education and "rh" for Race/Ethnicity |
all_groups |
default to true |
owner_code |
firm owner code |
geography |
the US Census geography granuality (one of cbsa or county) |
seasonadj |
seasonal adjustment factor (one of "U" or "S") |
apikey |
your US Census API Key |
processing |
the processing strategy (default = "sequential") |
the desired data from the US Census's Quaterly Workforce API as a tibble
## Not run: library(tidyqwi) # One state, one year nc_qwi <- get_qwi(years = "2010", states = "11", geography = "county", apikey = census_key, endpoint = "rh", variables = c("sEmp", "Emp"), all_groups = FALSE, industry_level = "2", processing = "sequential") # Multiple states. multiple years qwi_multi_year <- get_qwi(years = c("2010", "2011", "2012"), states = c("NC", "SC"), geography = "county", apikey = census_key, endpoint = "rh", variables = c("sEmp", "Emp"), all_groups = FALSE, industry_level = "2", processing = "sequential") ## End(Not run)
## Not run: library(tidyqwi) # One state, one year nc_qwi <- get_qwi(years = "2010", states = "11", geography = "county", apikey = census_key, endpoint = "rh", variables = c("sEmp", "Emp"), all_groups = FALSE, industry_level = "2", processing = "sequential") # Multiple states. multiple years qwi_multi_year <- get_qwi(years = c("2010", "2011", "2012"), states = c("NC", "SC"), geography = "county", apikey = census_key, endpoint = "rh", variables = c("sEmp", "Emp"), all_groups = FALSE, industry_level = "2", processing = "sequential") ## End(Not run)
These data are the industry labels specified by the United States Census Bureau
industry_labels
industry_labels
a dataframe with 433 rows and 3 columns:
Industry Numeric Code
Description of Industry Level
Industry Level
...
https://lehd.ces.census.gov/data/schema/latest/label_industry.csv
These data represent an example returned query for NC for 2010
nc_qwi
nc_qwi
a dataframe with 3244 rows and 44 columns:
Owner Codes
owner_codes
owner_codes
a dataframe with 3 rows and 2 columns:
ownercode
label
...
https://lehd.ces.census.gov/data/schema/latest/label_ownercode.csv
An internally used function to parse the returned API call.
parse_qwi_message(x)
parse_qwi_message(x)
x |
a returned call response from the US Census QWI API |
These data represent the different variable types available from the QWI API.
qwi_var_names
qwi_var_names
a dataframe with 83 rows and 9 columns:
state name
state fips code
state abbreviation
requirements
details of attributes
limit
predicate type
group level
values
...
https://api.census.gov/data/timeseries/qwi/se/variables.html
show_condition
show_condition(code)
show_condition(code)
code |
the code whose message you wish to interpret |
State Data (FIPS, Abbreviations, etc)
state_info
state_info
a dataframe with 51 rows and 3 columns:
state name
state fips code
state abbreviation
...
https://www.census.gov/library/reference/code-lists/ansi.html