Package 'tidyqwi'

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

Help Index


add_qwi_labels

Description

This function add labels to a 'qwi' object

Usage

add_qwi_labels(df)

Arguments

df

an object with a class of 'qwi'

Value

a data.frame with formatted column names and types

Examples

library(tidyqwi)

# Add labels
labelled_nc <- add_qwi_labels(nc_qwi)

# Check the label for the data
attr(labelled_nc[["Emp"]], "label")

A helper function to help parse API calls from the census

Description

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,

Usage

check_census_api_call(call)

Arguments

call

a returned call from the US Census API

Value

a string vector with the message from the US Census API

Examples

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)
}

A function to check if a valid state number or fips is passed

Description

The function verifies if a valid FIPS code was passed and converts it to a unified standard for internal use.

Usage

converted_fips(fips)

Arguments

fips

the state abbreviation or fips code vector

Value

States Abbreviations or FIPs as FIP character strings

a vector with the State FIPS code

Examples

library(tidyqwi)

converted_fips(37)
converted_fips("37")
converted_fips("NC")
converted_fips("nc")

Geographic Codes

Description

Geographic Codes

Usage

geo_codes

Format

a dataframe with 5423 rows and 3 columns:

geography

geography

label

label

geolevel

geolevel

...

Source

https://lehd.ces.census.gov/data/schema/latest/label_geography.csv


Retrieve the Quarterly Workforce Indcator Data

Description

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.

Usage

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"
)

Arguments

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")

Value

the desired data from the US Census's Quaterly Workforce API as a tibble

Examples

## 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)

Industry Labels

Description

These data are the industry labels specified by the United States Census Bureau

Usage

industry_labels

Format

a dataframe with 433 rows and 3 columns:

industry

Industry Numeric Code

label

Description of Industry Level

ind_level

Industry Level

...

Source

https://lehd.ces.census.gov/data/schema/latest/label_industry.csv


Example Data Set

Description

These data represent an example returned query for NC for 2010

Usage

nc_qwi

Format

a dataframe with 3244 rows and 44 columns:


Owner Codes

Description

Owner Codes

Usage

owner_codes

Format

a dataframe with 3 rows and 2 columns:

ownercode

ownercode

label

label

...

Source

https://lehd.ces.census.gov/data/schema/latest/label_ownercode.csv


parse_qwi

Description

An internally used function to parse the returned API call.

Usage

parse_qwi_message(x)

Arguments

x

a returned call response from the US Census QWI API


QWI Variable Names

Description

These data represent the different variable types available from the QWI API.

Usage

qwi_var_names

Format

a dataframe with 83 rows and 9 columns:

name

state name

label

state fips code

concept

state abbreviation

required

requirements

attributes

details of attributes

limit

limit

predicate type

predicate type

group

group level

values

values

...

Source

https://api.census.gov/data/timeseries/qwi/se/variables.html


show_condition

Description

show_condition

Usage

show_condition(code)

Arguments

code

the code whose message you wish to interpret


State Data (FIPS, Abbreviations, etc)

Description

State Data (FIPS, Abbreviations, etc)

Usage

state_info

Format

a dataframe with 51 rows and 3 columns:

name

state name

state_fips

state fips code

state_abbreviation

state abbreviation

...

Source

https://www.census.gov/library/reference/code-lists/ansi.html