~hrbrmstr/epidata

dc17d09a82427dfd2aadefdc7701fe872c6b320a — hrbrmstr a month ago 47b2d52 master
fix CRAN errors
M .Rbuildignore => .Rbuildignore +2 -1
@@ 1,3 1,4 @@
^CRAN-RELEASE$
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$


@@ 10,4 11,4 @@
^README\.*$
^README_files$
^cran-comments\.md$
^Dockerfile$
\ No newline at end of file
^Dockerfile$

A CRAN-RELEASE => CRAN-RELEASE +2 -0
@@ 0,0 1,2 @@
This package was submitted to CRAN on 2019-04-11.
Once it is accepted, delete this file and tag the release (commit 71bde7c94c).

M DESCRIPTION => DESCRIPTION +8 -9
@@ 1,8 1,8 @@
Package: epidata
Type: Package
Title: Tools to Retrieve Economic Policy Institute Data Library Extracts
Version: 0.3.0
Date: 2019-04-11
Version: 0.4.0
Date: 2020-08-25
Authors@R: c(person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")))
Maintainer: Bob Rudis <bob@rud.is>
Encoding: UTF-8


@@ 15,11 15,9 @@ Description: The Economic Policy Institute (<http://www.epi.org/>) provides
URL: https://gitlab.com/hrbrmstr/epidata
BugReports: https://gitlab.com/hrbrmstr/epidata/issues
License: AGPL
Suggests:
    testthat
Depends:
    R (>= 3.2.0)
Imports:
Depends: 
    R (>= 3.6.0)
Imports: 
    purrr,
    httr,
    jsonlite,


@@ 28,5 26,6 @@ Imports:
    xml2,
    tidyr,
    readr,
    stringi
RoxygenNote: 6.1.1
    stringi,
    tinytest
RoxygenNote: 7.1.1

M NAMESPACE => NAMESPACE +2 -1
@@ 25,9 25,9 @@ export(get_wage_decomposition)
export(get_wage_ratios)
export(get_wages_by_education)
export(get_wages_by_percentile)
export(not_dos)
import(httr)
importFrom(dplyr,"%>%")
importFrom(dplyr,as_data_frame)
importFrom(dplyr,mutate_all)
importFrom(jsonlite,fromJSON)
importFrom(purrr,"%||%")


@@ 44,4 44,5 @@ importFrom(stringi,stri_replace_all_fixed)
importFrom(stringi,stri_replace_all_regex)
importFrom(stringi,stri_trans_tolower)
importFrom(tidyr,gather)
importFrom(utils,getFromNamespace)
importFrom(xml2,read_html)

M R/aaa.r => R/aaa.r +12 -0
@@ 1,5 1,8 @@
globalVariables(c("date", "region", "value"))

as_data_frame <- function(x) {
  dplyr::as_tibble(as.data.frame(x))
}

httr::user_agent(
  sprintf(


@@ 8,3 11,12 @@ httr::user_agent(
    utils::packageDescription("epidata")$URL
  )
) -> .EPIDATA_UA


#' Not DoS'ing EPI/Cloudflare
#'
#' @return logical
#' @export
not_dos <- function() {
  utils::getFromNamespace("interactive", "base")()
}
\ No newline at end of file

M R/annual-wages-by-wage-group.R => R/annual-wages-by-wage-group.R +3 -1
@@ 23,14 23,16 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: SSA | Kopczuk, Saez, and Song (2010)
#' @return data frame
#' @export
#' @examples
#' get_annual_wages_by_wage_group()
#' if (not_dos()) get_annual_wages_by_wage_group()
get_annual_wages_by_wage_group <- function() {

  params <- list(subject="wagegroup")

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('%\\)]", "")

M R/compensation-wages-benefits.R => R/compensation-wages-benefits.R +3 -1
@@ 9,14 9,16 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: NIPA | ECEC
#' @return data frame
#' @export
#' @examples
#' get_compensation_wages_and_benefits()
#' if (not_dos()) get_compensation_wages_and_benefits()
get_compensation_wages_and_benefits <- function() {

  params <- list(subject="compben")

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('%,\\)]", "")

M R/employment.r => R/employment.r +11 -4
@@ 20,6 20,7 @@ get_unemployment <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 55,6 56,7 @@ get_unemployment_by_state <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("r"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 94,6 96,7 @@ get_long_term_unemployment <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 138,6 141,7 @@ get_underemployment <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 178,6 182,7 @@ get_labor_force_participation_rate <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 203,19 208,21 @@ get_labor_force_participation_rate <- function(by=NULL) {
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @export
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @return data frame
#' @examples
#' get_employment_to_population_ratio()
#' if (not_dos()) get_employment_to_population_ratio()
#'
#' get_employment_to_population_ratio("r")
#' if (not_dos()) get_employment_to_population_ratio("r")
#'
#' get_employment_to_population_ratio("grae")
#' if (not_dos()) get_employment_to_population_ratio("grae")
get_employment_to_population_ratio <- function(by=NULL) {

  params <- list(subject="lfpr")
  params <- list(subject="epop")

  if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/epi_query.r => R/epi_query.r +8 -2
@@ 5,7 5,10 @@ epi_query <- function(args) {

  httr::POST(
    "https://www.epi.org/wordpress/wp-admin/admin-ajax.php",
    httr::add_headers(`X-Requested-With`="XMLHttpRequest"),
    httr::add_headers(
      `X-Requested-With` = "XMLHttpRequest",
      `Referer` = "https://www.epi.org/data/"
    ),
    .EPIDATA_UA,
    encode = "form",
    body = list(


@@ 14,7 17,10 @@ epi_query <- function(args) {
    )
  ) -> res

  httr::stop_for_status(res)
  if (httr::status_code(res) != 200) {
    warning("EPI API is unresponsive. Please try again later.", call. = FALSE)
    return(NULL)
  }

  jsonlite::fromJSON(httr::content(res, as="text"), flatten=TRUE)


M R/epidata-package.R => R/epidata-package.R +2 -1
@@ 12,7 12,7 @@
#' @keywords internal
#' @importFrom purrr map map_df map_chr keep discard %||%
#' @importFrom stringi stri_replace_all_regex stri_trans_tolower %s+% stri_replace_all_fixed
#' @importFrom dplyr %>% as_data_frame mutate_all
#' @importFrom dplyr %>% mutate_all
#' @import httr
#' @importFrom readr type_convert
#' @importFrom jsonlite fromJSON


@@ 20,4 20,5 @@
#' @importFrom xml2 read_html
#' @importFrom tidyr gather
#' @importFrom stats setNames
#' @importFrom utils getFromNamespace
NULL

M R/gaps.r => R/gaps.r +11 -5
@@ 29,6 29,7 @@ get_gender_wage_gap <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("r"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 78,6 79,7 @@ get_black_white_wage_gap <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 127,6 129,7 @@ get_hispanic_white_wage_gap <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 167,6 170,7 @@ get_college_wage_premium <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 209,6 213,7 @@ get_non_high_school_wage_penalty <- function(by=NULL) {
  if (!is.null(by)) params <- make_params(params, by, c("g"))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 244,14 249,14 @@ get_non_high_school_wage_penalty <- function(by=NULL) {
#'   unemployment data by gender and race, you would set this parameter to "\code{gr}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @return data frame
#' @export
#' @examples \dontrun{
#' get_wage_ratios()
#' @examples
#' if (not_dos()) get_wage_ratios()
#'
#' get_wage_ratios("r")
#' if (not_dos()) get_wage_ratios("r")
#'
#' get_wage_ratios("gr")
#' }
#' if (not_dos()) get_wage_ratios("gr")
get_wage_ratios <- function(by=NULL) {

  params <- list(preset="wage-ratios")


@@ 262,6 267,7 @@ get_wage_ratios <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/health.r => R/health.r +5 -3
@@ 13,13 13,14 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: CPS ASEC
#' @return data frame
#' @export
#' @examples
#' get_health_insurance_coverage()
#' if (not_dos()) get_health_insurance_coverage()
#'
#' get_health_insurance_coverage("r")
#' if (not_dos()) get_health_insurance_coverage("r")
#'
#' get_health_insurance_coverage("gr")
#' if (not_dos()) get_health_insurance_coverage("gr")
get_health_insurance_coverage <- function(by=NULL) {

  params <- list(subject="healthcov")


@@ 30,6 31,7 @@ get_health_insurance_coverage <- function(by=NULL) {
  names(params) <- gsub("^l$", "el", names(params))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/minimum-wage.R => R/minimum-wage.R +3 -1
@@ 12,14 12,16 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: U.S. Department of Labor Wage and Hour Division | CES
#' @return data frame
#' @export
#' @examples
#' get_minimum_wage()
#' if (not_dos()) get_minimum_wage()
get_minimum_wage <- function() {

  params <- list(subject="minwage")

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('%,\\)]", "")

M R/pension.r => R/pension.r +5 -3
@@ 13,13 13,14 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: CPS ASEC
#' @return data frame
#' @export
#' @examples
#' get_health_insurance_coverage()
#' if (not_dos()) get_health_insurance_coverage()
#'
#' get_health_insurance_coverage("r")
#' if (not_dos()) get_health_insurance_coverage("r")
#'
#' get_health_insurance_coverage("gr")
#' if (not_dos()) get_health_insurance_coverage("gr")
get_pension_coverage <- function(by=NULL) {

  params <- list(subject="pensioncov")


@@ 30,6 31,7 @@ get_pension_coverage <- function(by=NULL) {
  names(params) <- gsub("^l$", "el", names(params))

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/poverty.R => R/poverty.R +6 -5
@@ 12,14 12,14 @@
#'   unemployment data by gender and race, you would set this parameter to "\code{gr}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @return data frame
#' @export
#' @examples \dontrun{
#' get_poverty_level_wages()
#' @examples
#' if (not_dos()) get_poverty_level_wages()
#'
#' get_poverty_level_wages("r")
#' if (not_dos()) get_poverty_level_wages("r")
#'
#' get_poverty_level_wages("gr")
#' }
#' if (not_dos()) get_poverty_level_wages("gr")
get_poverty_level_wages <- function(by=NULL) {

  params <- list(subject="povwage")


@@ 30,6 30,7 @@ get_poverty_level_wages <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('%\\+\\)]", "")

M R/productivity.r => R/productivity.r +4 -2
@@ 13,11 13,12 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: NIPA (compensation) | BLS Productivity Data
#' @return data frame
#' @export
#' @examples
#' get_productivity_and_hourly_compensation()
#' if (not_dos()) get_productivity_and_hourly_compensation()
#'
#' get_productivity_and_hourly_compensation("g")
#' if (not_dos()) get_productivity_and_hourly_compensation("g")
get_productivity_and_hourly_compensation <- function(by=NULL) {

  params <- list(subject="prodpay")


@@ 27,6 28,7 @@ get_productivity_and_hourly_compensation <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/union.r => R/union.r +3 -1
@@ 6,14 6,16 @@
#' @return \code{tbl_df}
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: CPS ORG | Hirsch and Macpherson (2003)
#' @return data frame
#' @export
#' @examples
#' get_union_coverage()
#' if (interactive()) get_union_coverage()
get_union_coverage <- function() {

  params <- list(subject="unioncov")

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/wage_decomposition.r => R/wage_decomposition.r +2 -0
@@ 11,6 11,7 @@
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note Data source: CPS ORG
#' @return data frame
#' @export
#' @examples
#' get_wages_by_percentile()


@@ 25,6 26,7 @@ get_wage_decomposition <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M R/wages.r => R/wages.r +4 -0
@@ 28,6 28,7 @@ get_median_and_mean_wages <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")


@@ 74,6 75,7 @@ get_wages_by_education <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%


@@ 101,6 103,7 @@ get_wages_by_education <- function(by=NULL) {
#'   unemployment data by gender and race, you would set this parameter to "\code{gr}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @return data frame
#' @export
#' @examples
#' get_wages_by_percentile()


@@ 118,6 121,7 @@ get_wages_by_percentile <- function(by=NULL) {
  }

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%

M R/wages_and_hours.r => R/wages_and_hours.r +2 -0
@@ 8,6 8,7 @@
#' @return \code{tbl_df}
#' @references \href{https://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @note CPS ASEC | Murphy and Welch (1989)
#' @return data frame
#' @export
#' @examples
#' get_annual_wages_and_work_hours()


@@ 16,6 17,7 @@ get_annual_wages_and_work_hours <- function() {
  params <- list(subject="hours")

  res <- epi_query(params)
  if (is.null(res)) return(data.frame())

  cols <- stringi::stri_trans_tolower(res$columns$name)
  cols <- stringi::stri_replace_all_regex(cols, "[\\('\\)]", "")

M README.Rmd => README.Rmd +66 -68
@@ 1,73 1,45 @@
---
output: rmarkdown::github_document
editor_options: 
  chunk_output_type: console
---

```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "##",
  fig.path = "man/figures/README-",
  out.width = "100%",
  message = FALSE,
  warning = FALSE
)
options(width=120)
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```

<!-- [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/epidata.svg?branch=master)](https://travis-ci.org/hrbrmstr/epidata) -->

# epidata

Tools to Retrieve Economic Policy Institute Data Library Extracts

## Description 
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```

The [Economic Policy Institute](http://www.epi.org/data/) provides researchers, media, and the public with easily accessible, up-to-date, and comprehensive historical data on the American labor force. It is compiled from Economic Policy Institute analysis of government data sources. Use it to research wages, inequality, and other economic indicators over time and among demographic groups. Data is usually updated monthly.
```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```

## What's Inside The Tin?
## What's Inside The Tin

The following functions are implemented:

- `get_annual_wages_and_work_hours`:	Retreive CPS ASEC Annual Wages and Work Hours
- `get_annual_wages_by_wage_group`:	Annual wages by wage group
- `get_black_white_wage_gap`:	Retreive the percent by which hourly wages of black workers are less than hourly wages of white workers
- `get_college_wage_premium`:	Retreive the percent by which hourly wages of college graduates exceed those of otherwise equivalent high school graduates
- `get_compensation_wages_and_benefits`:	Compensation, wages, and benefits
- `get_employment_to_population_ratio`:	Retreive the share of the civilian noninstitutional population that is employed
- `get_gender_wage_gap`:	Retreive the percent by which hourly wages of female workers are less than hourly wages of male workers
- `get_health_insurance_coverage`:	Retreive Health Insurance Coverage
- `get_hispanic_white_wage_gap`:	Retreive the percent by which hourly wages of Hispanic workers are less than hourly wages of white workers
- `get_labor_force_participation_rate`:	Retreive the share of the civilian noninstitutional population that is in the labor force
- `get_long_term_unemployment`:	Retreive the share of the labor force that has been unemployed for six months or longer
- `get_median_and_mean_wages`:	Retreive the hourly wage in the middle of the wage distribution
- `get_minimum_wage`:	Minimum wage
- `get_non_high_school_wage_penalty`:	Retreive the percent by which hourly wages of workers without a high school diploma (or equivalent) are less than wages of otherwise equivalent workers who have graduated from high school
- `get_pension_coverage`:	Retreive Pension Coverage
- `get_poverty_level_wages`:	Poverty-level wages
- `get_productivity_and_hourly_compensation`:	Retreive Productivity and hourly compensation
- `get_underemployment`:	Retreive the share of the labor force that is "underemployed"
- `get_unemployment`:	Retreive the share of the labor force without a job
- `get_unemployment_by_state`:	Retreive the share of the labor force without a job (by state)
- `get_union_coverage`:	Retreive Union Coverage
- `get_wages_by_education`:	Retreive the average hourly wages of workers disaggregated by the highest level of education attained
- `get_wages_by_percentile`:	Retreive wages at ten distinct points in the wage distribution
- `get_wage_decomposition`:	Retreive Wage Decomposition
- `get_wage_ratios`:	Retreive the level of inequality within the hourly wage distribution.
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```

## Installation

```{r eval=FALSE}
devtools::install_github("hrbrmstr/epidata")
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```

## Usage

```{r message=FALSE, warning=FALSE, error=FALSE}
```{r lib-ex}
library(epidata)

# current verison
# current version
packageVersion("epidata")

```

```{r ex01}
get_black_white_wage_gap()

get_underemployment()


@@ 77,7 49,7 @@ get_median_and_mean_wages("gr")

## Extended Example

```{r message=FALSE, warning=FALSE, error=FALSE, fig.width=10, fig.height=8, fig.retina=2}
```{r fig.width=10, fig.height=8, fig.retina=2}
library(tidyverse)
library(epidata)
library(ggrepel)


@@ 90,30 62,56 @@ glimpse(wages)

glimpse(unemployment)

group_by(unemployment, date=as.integer(lubridate::year(date))) %>%
  summarise(rate=mean(all)) %>%
  left_join(select(wages, date, median), by="date") %>%
unemployment %>% 
  group_by(date = as.integer(lubridate::year(date))) %>%
  summarise(rate = mean(all)) %>%
  left_join(select(wages, date, median), by = "date") %>%
  filter(!is.na(median)) %>%
  arrange(date) -> df
  arrange(date) -> xdf

cols <- ggthemes::tableau_color_pal()(3)

update_geom_font_defaults(font_rc)

ggplot(df, aes(rate, median)) +
  geom_path(color=cols[1], arrow=arrow(type="closed", length=unit(10, "points"))) +
ggplot(xdf, aes(rate, median)) +
  geom_path(
     color = cols[1], 
     arrow = arrow(
       type = "closed", 
       length = unit(10, "points")
    )
  ) +
  geom_point() +
  geom_label_repel(aes(label=date),
                   alpha=c(1, rep((4/5), (nrow(df)-2)), 1),
                   size=c(5, rep(3, (nrow(df)-2)), 5),
                   color=c(cols[2],
                           rep("#2b2b2b", (nrow(df)-2)),
                           cols[3]),
                   family=font_rc) +
  scale_x_continuous(name="Unemployment Rate", expand=c(0,0.001), label=scales::percent) +
  scale_y_continuous(name="Median Wage", expand=c(0,0.25), label=scales::dollar) +
  labs(title="U.S. Unemployment Rate vs Median Wage Since 1978",
       subtitle="Wage data is in 2015 USD",
       caption="Source: EPI analysis of Current Population Survey Outgoing Rotation Group microdata") +
  geom_label_repel(
    aes(label = date),
    alpha = c(1, rep((4/5), (nrow(xdf)-2)), 1),
    size = c(5, rep(3, (nrow(xdf)-2)), 5),
    color = c(cols[2], rep("#2b2b2b", (nrow(xdf)-2)), cols[3]),
    family = font_rc
  ) +
  scale_x_continuous(
    name = "Unemployment Rate", 
    expand = c(0,0.001), label = scales::percent
  ) +
  scale_y_continuous(
    name = "Median Wage", 
    expand = c(0,0.25), 
    label = scales::dollar
  ) +
  labs(
    title = "U.S. Unemployment Rate vs Median Wage Since 1978",
    subtitle = "Wage data is in 2015 USD",
    caption = "Source: EPI analysis of Current Population Survey Outgoing Rotation Group microdata"
  ) +
  theme_ipsum_rc(grid="XY")
```

## epidata Metrics

```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

M README.md => README.md +131 -68
@@ 1,5 1,22 @@

<!-- [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/epidata.svg?branch=master)](https://travis-ci.org/hrbrmstr/epidata) -->
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-36%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/epidata.svg?branch=master)](https://travis-ci.org/hrbrmstr/epidata)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/epidata/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/epidata)
[![cran
checks](https://cranchecks.info/badges/worst/epidata)](https://cranchecks.info/pkgs/epidata)
[![CRAN
status](https://www.r-pkg.org/badges/version/epidata)](https://www.r-pkg.org/pkg/epidata)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg)
![License](https://img.shields.io/badge/License-AGPL-blue.svg)

# epidata



@@ 7,7 24,7 @@ Tools to Retrieve Economic Policy Institute Data Library Extracts

## Description

The [Economic Policy Institute](http://www.epi.org/data/) provides
The Economic Policy Institute (<http://www.epi.org/>) provides
researchers, media, and the public with easily accessible, up-to-date,
and comprehensive historical data on the American labor force. It is
compiled from Economic Policy Institute analysis of government data


@@ 15,7 32,7 @@ sources. Use it to research wages, inequality, and other economic
indicators over time and among demographic groups. Data is usually
updated monthly.

## What’s Inside The Tin?
## What’s Inside The Tin

The following functions are implemented:



@@ 54,81 71,95 @@ The following functions are implemented:
    and hourly compensation
  - `get_underemployment`: Retreive the share of the labor force that is
    “underemployed”
  - `get_unemployment`: Retreive the share of the labor force without a
    job
  - `get_unemployment_by_state`: Retreive the share of the labor force
    without a job (by state)
  - `get_unemployment`: Retreive the share of the labor force without a
    job
  - `get_union_coverage`: Retreive Union Coverage
  - `get_wage_decomposition`: Retreive Wage Decomposition
  - `get_wage_ratios`: Retreive the level of inequality within the
    hourly wage distribution.
  - `get_wages_by_education`: Retreive the average hourly wages of
    workers disaggregated by the highest level of education attained
  - `get_wages_by_percentile`: Retreive wages at ten distinct points in
    the wage distribution
  - `get_wage_decomposition`: Retreive Wage Decomposition
  - `get_wage_ratios`: Retreive the level of inequality within the
    hourly wage distribution.
  - `not_dos`: Not DoS’ing EPI/Cloudflare

## Installation

``` r
devtools::install_github("hrbrmstr/epidata")
install.packages("epidata") # NOTE: CRAN version is 0.3.0
# or
install.packages("epidata", repos = c("https://cinc.rud.is", "https://cloud.r-project.org/"))
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/epidata")
# or
remotes::install_gitlab("hrbrmstr/epidata")
# or
remotes::install_github("hrbrmstr/epidata")
```

NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.

## Usage

``` r
library(epidata)

# current verison
# current version
packageVersion("epidata")
## [1] '0.3.0'
## [1] '0.4.0'
```

``` r
get_black_white_wage_gap()
## # A tibble: 46 x 8
## # A tibble: 47 x 8
##     date white_median white_average black_median black_average gap_median gap_average gap_regression_based
##    <dbl>        <dbl>         <dbl>        <dbl>         <dbl>      <dbl>       <dbl>                <dbl>
##  1  1973         17.6          20.4         13.7          16.0      0.223       0.215              NA     
##  2  1974         17.2          19.9         13.8          15.8      0.198       0.209              NA     
##  3  1975         17.1          20           13.9          15.8      0.191       0.208              NA     
##  4  1976         17.2          20.1         14.0          16.5      0.19        0.182              NA     
##  5  1977         17.2          20.1         13.9          16.2      0.188       0.19               NA     
##  6  1978         17.4          20.1         13.9          16.4      0.201       0.186              NA     
##  7  1979         17.1          20.3         14.3          16.8      0.164       0.173               0.086 
##  8  1980         17.1          19.9         14.1          16.4      0.173       0.174               0.086 
##  9  1981         16.7          19.8         13.8          16.4      0.175       0.174               0.0820
## 10  1982         16.9          20.0         13.7          16.2      0.194       0.191               0.099 
## # … with 36 more rows
##  1  1973         17.9          20.7         14.0          16.3      0.223       0.215              NA     
##  2  1974         17.5          20.3         14.0          16.0      0.198       0.209              NA     
##  3  1975         17.4          20.4         14.1          16.1      0.191       0.208              NA     
##  4  1976         17.5          20.5         14.2          16.8      0.19        0.182              NA     
##  5  1977         17.5          20.4         14.2          16.5      0.188       0.19               NA     
##  6  1978         17.7          20.5         14.2          16.7      0.201       0.186              NA     
##  7  1979         17.4          20.7         14.6          17.1      0.164       0.173               0.086 
##  8  1980         17.4          20.3         14.4          16.7      0.173       0.174               0.086 
##  9  1981         17.0          20.2         14.0          16.6      0.175       0.174               0.0820
## 10  1982         17.2          20.4         13.9          16.5      0.194       0.191               0.099 
## # … with 37 more rows

get_underemployment()
## # A tibble: 325 x 2
## # A tibble: 367 x 2
##    date         all
##    <date>     <dbl>
##  1 1989-12-01 0.093
##  1 1989-12-01 0.094
##  2 1990-01-01 0.093
##  3 1990-02-01 0.093
##  3 1990-02-01 0.094
##  4 1990-03-01 0.094
##  5 1990-04-01 0.094
##  6 1990-05-01 0.094
##  7 1990-06-01 0.094
##  8 1990-07-01 0.094
##  9 1990-08-01 0.095
## 10 1990-09-01 0.095
## # … with 315 more rows
## 10 1990-09-01 0.096
## # … with 357 more rows

get_median_and_mean_wages("gr")
## # A tibble: 46 x 25
## # A tibble: 47 x 25
##     date median average men_median men_average women_median women_average white_median white_average black_median
##    <dbl>  <dbl>   <dbl>      <dbl>       <dbl>        <dbl>         <dbl>        <dbl>         <dbl>        <dbl>
##  1  1973   17.0    19.7       20.6        23.1         13.0          14.9         17.6          20.4         13.7
##  2  1974   16.6    19.4       20.3        22.7         12.8          14.6         17.2          19.9         13.8
##  3  1975   16.6    19.4       20.7        22.7         12.9          14.8         17.1          20           13.9
##  4  1976   16.6    19.6       20.3        22.9         13.1          15.1         17.2          20.1         14.0
##  5  1977   16.6    19.5       20.5        22.9         13.0          15.0         17.2          20.1         13.9
##  6  1978   16.8    19.6       20.8        23.0         13.0          15.0         17.4          20.1         13.9
##  7  1979   16.5    19.7       20.7        23.2         13.1          15.2         17.1          20.3         14.3
##  8  1980   16.4    19.4       20.5        22.8         13.1          15.1         17.1          19.9         14.1
##  9  1981   16.2    19.2       20.1        22.6         13.1          15.1         16.7          19.8         13.8
## 10  1982   16.1    19.4       20.1        22.8         13.0          15.3         16.9          20.0         13.7
## # … with 36 more rows, and 15 more variables: black_average <dbl>, hispanic_median <dbl>, hispanic_average <dbl>,
##  1  1973   17.3    20.1       21.0        23.6         13.2          15.1         17.9          20.7         14.0
##  2  1974   16.9    19.7       20.7        23.1         13            14.9         17.5          20.3         14.0
##  3  1975   16.9    19.8       21.0        23.1         13.2          15.1         17.4          20.4         14.1
##  4  1976   16.9    20.0       20.7        23.4         13.3          15.4         17.5          20.5         14.2
##  5  1977   16.9    19.9       20.9        23.4         13.2          15.2         17.5          20.4         14.2
##  6  1978   17.1    19.9       21.2        23.5         13.2          15.3         17.7          20.5         14.2
##  7  1979   16.8    20.1       21.1        23.7         13.4          15.5         17.4          20.7         14.6
##  8  1980   16.7    19.7       20.9        23.2         13.3          15.3         17.4          20.3         14.4
##  9  1981   16.5    19.6       20.4        23.0         13.4          15.3         17.0          20.2         14.0
## 10  1982   16.4    19.8       20.4        23.2         13.2          15.6         17.2          20.4         13.9
## # … with 37 more rows, and 15 more variables: black_average <dbl>, hispanic_median <dbl>, hispanic_average <dbl>,
## #   white_men_median <dbl>, white_men_average <dbl>, black_men_median <dbl>, black_men_average <dbl>,
## #   hispanic_men_median <dbl>, hispanic_men_average <dbl>, white_women_median <dbl>, white_women_average <dbl>,
## #   black_women_median <dbl>, black_women_average <dbl>, hispanic_women_median <dbl>, hispanic_women_average <dbl>


@@ 146,44 177,76 @@ unemployment <- get_unemployment()
wages <- get_median_and_mean_wages()

glimpse(wages)
## Observations: 46
## Variables: 3
## Rows: 47
## Columns: 3
## $ date    <dbl> 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989,…
## $ median  <dbl> 16.96, 16.63, 16.64, 16.60, 16.62, 16.77, 16.49, 16.38, 16.21, 16.14, 16.17, 16.26, 16.51, 16.62, 16.…
## $ average <dbl> 19.73, 19.37, 19.41, 19.63, 19.53, 19.57, 19.74, 19.35, 19.24, 19.41, 19.45, 19.52, 19.73, 20.20, 20.…
## $ median  <dbl> 17.27, 16.93, 16.94, 16.90, 16.92, 17.07, 16.79, 16.68, 16.50, 16.43, 16.47, 16.55, 16.81, 16.92, 17.…
## $ average <dbl> 20.09, 19.72, 19.77, 19.99, 19.88, 19.92, 20.10, 19.70, 19.59, 19.76, 19.80, 19.87, 20.08, 20.57, 20.…

glimpse(unemployment)
## Observations: 457
## Variables: 2
## $ date <date> 1978-12-01, 1979-01-01, 1979-02-01, 1979-03-01, 1979-04-01, 1979-05-01, 1979-06-01, 1979-07-01, 1979-08…
## $ all  <dbl> 0.061, 0.061, 0.060, 0.060, 0.059, 0.059, 0.059, 0.058, 0.058, 0.058, 0.059, 0.059, 0.059, 0.059, 0.059,…

group_by(unemployment, date=as.integer(lubridate::year(date))) %>%
  summarise(rate=mean(all)) %>%
  left_join(select(wages, date, median), by="date") %>%
## Rows: 510
## Columns: 2
## $ date <date> 1978-01-01, 1978-02-01, 1978-03-01, 1978-04-01, 1978-05-01, 1978-06-01, 1978-07-01, 1978-08-01, 1978-09…
## $ all  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.061, 0.061, 0.060, 0.060, 0.059, 0.059, 0.059, 0.058, 0.05…

unemployment %>% 
  group_by(date = as.integer(lubridate::year(date))) %>%
  summarise(rate = mean(all)) %>%
  left_join(select(wages, date, median), by = "date") %>%
  filter(!is.na(median)) %>%
  arrange(date) -> df
  arrange(date) -> xdf

cols <- ggthemes::tableau_color_pal()(3)

update_geom_font_defaults(font_rc)

ggplot(df, aes(rate, median)) +
  geom_path(color=cols[1], arrow=arrow(type="closed", length=unit(10, "points"))) +
ggplot(xdf, aes(rate, median)) +
  geom_path(
     color = cols[1], 
     arrow = arrow(
       type = "closed", 
       length = unit(10, "points")
    )
  ) +
  geom_point() +
  geom_label_repel(aes(label=date),
                   alpha=c(1, rep((4/5), (nrow(df)-2)), 1),
                   size=c(5, rep(3, (nrow(df)-2)), 5),
                   color=c(cols[2],
                           rep("#2b2b2b", (nrow(df)-2)),
                           cols[3]),
                   family=font_rc) +
  scale_x_continuous(name="Unemployment Rate", expand=c(0,0.001), label=scales::percent) +
  scale_y_continuous(name="Median Wage", expand=c(0,0.25), label=scales::dollar) +
  labs(title="U.S. Unemployment Rate vs Median Wage Since 1978",
       subtitle="Wage data is in 2015 USD",
       caption="Source: EPI analysis of Current Population Survey Outgoing Rotation Group microdata") +
  geom_label_repel(
    aes(label = date),
    alpha = c(1, rep((4/5), (nrow(xdf)-2)), 1),
    size = c(5, rep(3, (nrow(xdf)-2)), 5),
    color = c(cols[2], rep("#2b2b2b", (nrow(xdf)-2)), cols[3]),
    family = font_rc
  ) +
  scale_x_continuous(
    name = "Unemployment Rate", 
    expand = c(0,0.001), label = scales::percent
  ) +
  scale_y_continuous(
    name = "Median Wage", 
    expand = c(0,0.25), 
    label = scales::dollar
  ) +
  labs(
    title = "U.S. Unemployment Rate vs Median Wage Since 1978",
    subtitle = "Wage data is in 2015 USD",
    caption = "Source: EPI analysis of Current Population Survey Outgoing Rotation Group microdata"
  ) +
  theme_ipsum_rc(grid="XY")
```

<img src="man/figures/README-unnamed-chunk-4-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-1-1.png" width="960" />

## epidata Metrics

| Lang | \# Files |  (%) | LoC |  (%) | Blank lines |  (%) | \# Lines |  (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| R    |       18 | 0.47 | 516 | 0.45 |         205 | 0.44 |      508 | 0.47 |
| Rmd  |        1 | 0.03 |  58 | 0.05 |          27 | 0.06 |       32 | 0.03 |
| SUM  |       19 | 0.50 | 574 | 0.50 |         232 | 0.50 |      540 | 0.50 |

clock Package Metrics for epidata

## Code of Conduct

Please note that this project is released with a Contributor Code of
Conduct. By participating in this project you agree to abide by its
terms.

A cran-comments.md => cran-comments.md +18 -0
@@ 0,0 1,18 @@
## Test environments
* local OS X install, R 3.5.3
* ubuntu 14.04 (on travis-ci), R 3.5.3
* win-builder (devel and release)
* r-hub (windows) (devel and release)

## R CMD check results

0 errors | 0 warnings | 1 note

* the usual maintainer note

Per Kurt's email I have fixed the CRAN check issues. I have
also added four new functions (for four new API endpoints),
changed out http: URLS in the documentation to https:
and re-generated all documentation and README files.

Thx, as always, for your combined diligence!

A inst/tinytest/test_epidata.R => inst/tinytest/test_epidata.R +31 -0
@@ 0,0 1,31 @@
library(epidata)

if (at_home()) {
  suppressMessages(expect_true(inherits(get_annual_wages_and_work_hours(), "data.frame")))
  # expect_true(inherits(get_annual_wages_by_wage_group(), "data.frame"))
  # expect_true(inherits(get_black_white_wage_gap(), "data.frame"))
  # expect_true(inherits(get_college_wage_premium(), "data.frame"))
  # expect_true(inherits(get_compensation_wages_and_benefits(), "data.frame"))
  # expect_true(inherits(get_employment_to_population_ratio(), "data.frame"))
  # expect_true(inherits(get_gender_wage_gap(), "data.frame"))
  # expect_true(inherits(get_health_insurance_coverage(), "data.frame"))
  # expect_true(inherits(get_hispanic_white_wage_gap(), "data.frame"))
  # expect_true(inherits(get_labor_force_participation_rate(), "data.frame"))
  # expect_true(inherits(get_long_term_unemployment(), "data.frame"))
  # expect_true(inherits(get_median_and_mean_wages(), "data.frame"))
  # expect_true(inherits(get_minimum_wage(), "data.frame"))
  # expect_true(inherits(get_non_high_school_wage_penalty(), "data.frame"))
  # expect_true(inherits(get_pension_coverage(), "data.frame"))
  # expect_true(inherits(get_poverty_level_wages(), "data.frame"))
  # expect_true(inherits(get_productivity_and_hourly_compensation(), "data.frame"))
  # expect_true(inherits(get_underemployment(), "data.frame"))
  # expect_true(inherits(get_unemployment(), "data.frame"))
  # expect_true(inherits(get_unemployment_by_state(), "data.frame"))
  # expect_true(inherits(get_union_coverage(), "data.frame"))
  # expect_true(inherits(get_wages_by_education(), "data.frame"))
  # expect_true(inherits(get_wages_by_percentile(), "data.frame"))
  # expect_true(inherits(get_wage_decomposition(), "data.frame"))
  # expect_true(inherits(get_wage_ratios(), "data.frame"))
} else {
  expect_false(not_dos())
}
\ No newline at end of file

M man/epidata.Rd => man/epidata.Rd +0 -1
@@ 3,7 3,6 @@
\docType{package}
\name{epidata}
\alias{epidata}
\alias{epidata-package}
\title{A package to Tools to Retrieve Economic Policy Institute Data Library Extracts}
\description{
The Economic Policy Institute provides researchers, media, and the public with easily

A man/figures/README-unnamed-chunk-1-1.png => man/figures/README-unnamed-chunk-1-1.png +0 -0

M man/get_annual_wages_and_work_hours.Rd => man/get_annual_wages_and_work_hours.Rd +2 -0
@@ 8,6 8,8 @@ get_annual_wages_and_work_hours()
}
\value{
\code{tbl_df}

data frame
}
\description{
Annual, weekly, and hourly wages and work hours show the average wages and work hours

M man/get_annual_wages_by_wage_group.Rd => man/get_annual_wages_by_wage_group.Rd +3 -1
@@ 8,6 8,8 @@ get_annual_wages_by_wage_group()
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Return the average annual salaries for select wage groups, with particular focus on


@@ 35,7 37,7 @@ detailed explanation, see the methodology for annual wages and hours.
Data source: SSA | Kopczuk, Saez, and Song (2010)
}
\examples{
get_annual_wages_by_wage_group()
if (not_dos()) get_annual_wages_by_wage_group()
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_compensation_wages_and_benefits.Rd => man/get_compensation_wages_and_benefits.Rd +3 -1
@@ 8,6 8,8 @@ get_compensation_wages_and_benefits()
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Return the nonwage payments, referred to as fringe benefits, and wages.


@@ 21,7 23,7 @@ Wages are in 2016 dollars. Wage and salary workers (NIPA) | Private-sector worke
Data source: NIPA | ECEC
}
\examples{
get_compensation_wages_and_benefits()
if (not_dos()) get_compensation_wages_and_benefits()
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_employment_to_population_ratio.Rd => man/get_employment_to_population_ratio.Rd +5 -3
@@ 13,16 13,18 @@ unemployment data by gender, race and education, you would set this parameter to
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Retreive the share of the civilian noninstitutional population that is employed
}
\examples{
get_employment_to_population_ratio()
if (not_dos()) get_employment_to_population_ratio()

get_employment_to_population_ratio("r")
if (not_dos()) get_employment_to_population_ratio("r")

get_employment_to_population_ratio("grae")
if (not_dos()) get_employment_to_population_ratio("grae")
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_health_insurance_coverage.Rd => man/get_health_insurance_coverage.Rd +5 -3
@@ 14,6 14,8 @@ parameter to "\code{gr}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Employer-sponsored health insurance (ESI) coverage shows the share of workers who


@@ 27,11 29,11 @@ Population sample: Private-sector workers age 18–64 & at least 20 hours/week a
Data source: CPS ASEC
}
\examples{
get_health_insurance_coverage()
if (not_dos()) get_health_insurance_coverage()

get_health_insurance_coverage("r")
if (not_dos()) get_health_insurance_coverage("r")

get_health_insurance_coverage("gr")
if (not_dos()) get_health_insurance_coverage("gr")
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_minimum_wage.Rd => man/get_minimum_wage.Rd +3 -1
@@ 8,6 8,8 @@ get_minimum_wage()
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Return tthe hourly minimum wage set by federal law. The real minimum wage is the federal


@@ 24,7 26,7 @@ Population sample: Production and nonsupervisory workers (average wages)
Data source: U.S. Department of Labor Wage and Hour Division | CES
}
\examples{
get_minimum_wage()
if (not_dos()) get_minimum_wage()
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_pension_coverage.Rd => man/get_pension_coverage.Rd +5 -3
@@ 14,6 14,8 @@ parameter to "\code{gr}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Employer-provided pension coverage shows the share of workers included in an


@@ 27,11 29,11 @@ Population sample: Private-sector workers age 18–64 & at least 20 hours/week a
Data source: CPS ASEC
}
\examples{
get_health_insurance_coverage()
if (not_dos()) get_health_insurance_coverage()

get_health_insurance_coverage("r")
if (not_dos()) get_health_insurance_coverage("r")

get_health_insurance_coverage("gr")
if (not_dos()) get_health_insurance_coverage("gr")
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_poverty_level_wages.Rd => man/get_poverty_level_wages.Rd +5 -5
@@ 13,6 13,8 @@ unemployment data by gender and race, you would set this parameter to "\code{gr}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Return the share of workers earning equal to or less than the poverty-level wage, or


@@ 24,13 26,11 @@ Population sample: Wage and salary workers age 18–64. Data source: CPS ORG | C
Bureau (poverty threshold)
}
\examples{
\dontrun{
get_poverty_level_wages()
if (not_dos()) get_poverty_level_wages()

get_poverty_level_wages("r")
if (not_dos()) get_poverty_level_wages("r")

get_poverty_level_wages("gr")
}
if (not_dos()) get_poverty_level_wages("gr")
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_productivity_and_hourly_compensation.Rd => man/get_productivity_and_hourly_compensation.Rd +4 -2
@@ 11,6 11,8 @@ get_productivity_and_hourly_compensation(by = NULL)
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Productivity is how much workers produce per hour, or the growth of output of goods and


@@ 27,9 29,9 @@ Population sample: All workers & Production and nonsupervisory workers
Data source: NIPA (compensation) | BLS Productivity Data
}
\examples{
get_productivity_and_hourly_compensation()
if (not_dos()) get_productivity_and_hourly_compensation()

get_productivity_and_hourly_compensation("g")
if (not_dos()) get_productivity_and_hourly_compensation("g")
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_union_coverage.Rd => man/get_union_coverage.Rd +3 -1
@@ 8,6 8,8 @@ get_union_coverage()
}
\value{
\code{tbl_df}

data frame
}
\description{
The union coverage rate shows the percentage of the workforce covered by a collective


@@ 17,7 19,7 @@ bargaining agreement.
Data source: CPS ORG | Hirsch and Macpherson (2003)
}
\examples{
get_union_coverage()
if (interactive()) get_union_coverage()
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_wage_decomposition.Rd => man/get_wage_decomposition.Rd +2 -0
@@ 11,6 11,8 @@ get_wage_decomposition(by = NULL)
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Wage inequality data shows the overall wage inequality and the within-group and

M man/get_wage_ratios.Rd => man/get_wage_ratios.Rd +5 -5
@@ 13,6 13,8 @@ unemployment data by gender and race, you would set this parameter to "\code{gr}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
The 95–50 and 50–10 wage ratios are representations of the level of inequality within


@@ 28,13 30,11 @@ top and the middle or the middle and the bottom of the wage distribution.
}
}
\examples{
\dontrun{
get_wage_ratios()
if (not_dos()) get_wage_ratios()

get_wage_ratios("r")
if (not_dos()) get_wage_ratios("r")

get_wage_ratios("gr")
}
if (not_dos()) get_wage_ratios("gr")
}
\references{
\href{https://www.epi.org/data/}{Economic Policy Institute Data Library}

M man/get_wages_by_percentile.Rd => man/get_wages_by_percentile.Rd +2 -0
@@ 13,6 13,8 @@ unemployment data by gender and race, you would set this parameter to "\code{gr}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.

data frame
}
\description{
Wage percentiles are wages at ten distinct points in the wage distribution: deciles

A man/not_dos.Rd => man/not_dos.Rd +14 -0
@@ 0,0 1,14 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/aaa.r
\name{not_dos}
\alias{not_dos}
\title{Not DoS'ing EPI/Cloudflare}
\usage{
not_dos()
}
\value{
logical
}
\description{
Not DoS'ing EPI/Cloudflare
}

D tests/test-all.R => tests/test-all.R +0 -2
@@ 1,2 0,0 @@
library(testthat)
test_check("epidata")

D tests/testthat/test-epidata.R => tests/testthat/test-epidata.R +0 -32
@@ 1,32 0,0 @@
context("API endpoints")
test_that("All API endpoints work as expected", {

  testthat::skip_on_cran()

  expect_that(get_annual_wages_and_work_hours(), is_a("data.frame"))
  expect_that(get_annual_wages_by_wage_group(), is_a("data.frame"))
  expect_that(get_black_white_wage_gap(), is_a("data.frame"))
  expect_that(get_college_wage_premium(), is_a("data.frame"))
  expect_that(get_compensation_wages_and_benefits(), is_a("data.frame"))
  expect_that(get_employment_to_population_ratio(), is_a("data.frame"))
  expect_that(get_gender_wage_gap(), is_a("data.frame"))
  expect_that(get_health_insurance_coverage(), is_a("data.frame"))
  expect_that(get_hispanic_white_wage_gap(), is_a("data.frame"))
  expect_that(get_labor_force_participation_rate(), is_a("data.frame"))
  expect_that(get_long_term_unemployment(), is_a("data.frame"))
  expect_that(get_median_and_mean_wages(), is_a("data.frame"))
  expect_that(get_minimum_wage(), is_a("data.frame"))
  expect_that(get_non_high_school_wage_penalty(), is_a("data.frame"))
  expect_that(get_pension_coverage(), is_a("data.frame"))
  expect_that(get_poverty_level_wages(), is_a("data.frame"))
  expect_that(get_productivity_and_hourly_compensation(), is_a("data.frame"))
  expect_that(get_underemployment(), is_a("data.frame"))
  expect_that(get_unemployment(), is_a("data.frame"))
  expect_that(get_unemployment_by_state(), is_a("data.frame"))
  expect_that(get_union_coverage(), is_a("data.frame"))
  expect_that(get_wages_by_education(), is_a("data.frame"))
  expect_that(get_wages_by_percentile(), is_a("data.frame"))
  expect_that(get_wage_decomposition(), is_a("data.frame"))
  expect_that(get_wage_ratios(), is_a("data.frame"))

})

A tests/tinytest.R => tests/tinytest.R +5 -0
@@ 0,0 1,5 @@

if ( requireNamespace("tinytest", quietly=TRUE) ){
  tinytest::test_package("epidata")
}