Browse Source

initial commit

master
boB Rudis 7 years ago
commit
3a7061e2bd
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 7
      .Rbuildignore
  2. 7
      .gitignore
  3. 24
      .travis.yml
  4. 32
      DESCRIPTION
  5. 36
      NAMESPACE
  6. 5
      NEWS.md
  7. 1
      R/aaa.r
  8. 234
      R/employment.r
  9. 16
      R/epi_query.r
  10. 22
      R/epidata-package.R
  11. 283
      R/gaps.r
  12. 23
      R/utils.r
  13. 136
      R/wages.r
  14. 75
      README.Rmd
  15. 124
      README.md
  16. 21
      epidata.Rproj
  17. 18
      man/epidata.Rd
  18. 42
      man/get_black_white_wage_gap.Rd
  19. 32
      man/get_college_wage_premium.Rd
  20. 32
      man/get_employment_to_population_ratio.Rd
  21. 41
      man/get_gender_wage_gap.Rd
  22. 42
      man/get_hispanic_white_wage_gap.Rd
  23. 32
      man/get_labor_force_participation_rate.Rd
  24. 32
      man/get_long_term_unemployment.Rd
  25. 35
      man/get_median_and_mean_wages.Rd
  26. 33
      man/get_non_high_school_wage_penalty.Rd
  27. 36
      man/get_underemployment.Rd
  28. 35
      man/get_unemployment.Rd
  29. 31
      man/get_unemployment_by_state.Rd
  30. 42
      man/get_wage_ratios.Rd
  31. 35
      man/get_wages_by_education.Rd
  32. 34
      man/get_wages_by_percentile.Rd
  33. 2
      tests/test-all.R
  34. 23
      tests/testthat/test-epidata.R

7
.Rbuildignore

@ -0,0 +1,7 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^README\.*Rmd$
^README\.*html$
^NOTES\.*Rmd$
^NOTES\.*html$

7
.gitignore

@ -0,0 +1,7 @@
.Rproj.user
.Rhistory
.RData
.Rproj
src/*.o
src/*.so
src/*.dll

24
.travis.yml

@ -0,0 +1,24 @@
language: r
warnings_are_errors: true
sudo: required
r:
- oldrel
- release
- devel
apt_packages:
- libv8-dev
- xclip
env:
global:
- CRAN: http://cran.rstudio.com
notifications:
email:
- bob@rud.is
irc:
channels:
- "104.236.112.222#builds"
nick: travisci

32
DESCRIPTION

@ -0,0 +1,32 @@
Package: epidata
Type: Package
Title: Tools to Retrieve Economic Policy Institute Data Library Extracts
Version: 0.1.0
Date: 2017-01-04
Author: Bob Rudis (bob@@rud.is)
Encoding: UTF-8
Maintainer: Bob Rudis <bob@rud.is>
Description: The Economic Policy Institute 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.
URL: https://github.com/hrbrmstr/epidata
BugReports: https://github.com/hrbrmstr/epidata/issues
License: AGPL
Suggests:
testthat
Depends:
R (>= 3.2.0)
Imports:
purrr,
httr,
jsonlite,
dplyr,
rvest,
xml2,
tidyr,
readr,
stringi
RoxygenNote: 5.0.1

36
NAMESPACE

@ -0,0 +1,36 @@
# Generated by roxygen2: do not edit by hand
export(get_black_white_wage_gap)
export(get_college_wage_premium)
export(get_employment_to_population_ratio)
export(get_gender_wage_gap)
export(get_hispanic_white_wage_gap)
export(get_labor_force_participation_rate)
export(get_long_term_unemployment)
export(get_median_and_mean_wages)
export(get_non_high_school_wage_penalty)
export(get_underemployment)
export(get_unemployment)
export(get_unemployment_by_state)
export(get_wage_ratios)
export(get_wages_by_education)
export(get_wages_by_percentile)
import(httr)
importFrom(dplyr,"%>%")
importFrom(dplyr,as_data_frame)
importFrom(dplyr,mutate_all)
importFrom(jsonlite,fromJSON)
importFrom(purrr,"%||%")
importFrom(purrr,discard)
importFrom(purrr,keep)
importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_df)
importFrom(readr,type_convert)
importFrom(rvest,html_text)
importFrom(stats,setNames)
importFrom(stringi,"%s+%")
importFrom(stringi,stri_replace_all_regex)
importFrom(stringi,stri_trans_tolower)
importFrom(tidyr,gather)
importFrom(xml2,read_html)

5
NEWS.md

@ -0,0 +1,5 @@
0.1.0
* Passes CRAN checks
* Complete EPI SWADL hidden API coverage
* Initial release

1
R/aaa.r

@ -0,0 +1 @@
globalVariables(c("date", "region", "value"))

234
R/employment.r

@ -0,0 +1,234 @@
#' Retreive the share of the labor force without a job
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender),
#' \code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
#' unemployment data by gender, race and education, you would set this parameter to "\code{gre}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @note See \code{get_unemployment_by_state()} for information on retrieving unemployment by state+race.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_unemployment()
#'
#' get_unemployment("r")
#'
#' get_unemployment("grae")
#' }
get_unemployment <- function(by=NULL) {
params <- list(subject="unemp")
if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the share of the labor force without a job (by state)
#'
#' @param by \code{NULL} or \code{r} for a partition by race.
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @note See \code{get_unemployment()} for other unemployment extracts..
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_unemployment_by_state()
#'
#' get_unemployment_by_state("r")
#' }
get_unemployment_by_state <- function(by=NULL) {
params <- list(subject="unempstate")
if (!is.null(by)) params <- make_params(params, by, c("r"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
out <- tidyr::gather(out, region, value, -date)
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the share of the labor force that has been unemployed for six months or longer
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender),
#' \code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
#' unemployment data by gender, race and education, you would set this parameter to "\code{gre}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_long_term_unemployment()
#'
#' get_long_term_unemployment("r")
#'
#' get_long_term_unemployment("grae")
#' }
get_long_term_unemployment <- function(by=NULL) {
params <- list(subject="ltunemp")
if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the share of the labor force that is "underemployed"
#'
#' Underemployment is the share of the labor force that either 1) is unemployed, 2) is
#' working part time but wants and is available to work full time (an "involuntary" part
#' timer), or 3) wants and is available to work and has looked for work in the last year
#' but has given up actively seeking work in the last four weeks ("marginally attached"
#' worker).
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender),
#' \code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
#' unemployment data by gender, race and education, you would set this parameter to "\code{gre}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_underemployment()
#'
#' get_underemployment("r")
#'
#' get_underemployment("grae")
#' }
get_underemployment <- function(by=NULL) {
params <- list(subject="underemp")
if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the share of the civilian noninstitutional population that is in the labor force
#'
#' (i.e., working or looking for work)
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender),
#' \code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
#' unemployment data by gender, race and education, you would set this parameter to "\code{gre}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_labor_force_participation_rate()
#'
#' get_labor_force_participation_rate("r")
#'
#' get_labor_force_participation_rate("grae")
#' }
get_labor_force_participation_rate <- function(by=NULL) {
params <- list(subject="lfpr")
if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the share of the civilian noninstitutional population that is employed
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender),
#' \code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
#' unemployment data by gender, race and education, you would set this parameter to "\code{gre}".
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @export
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @examples \dontrun{
#' get_employment_to_population_ratio()
#'
#' get_employment_to_population_ratio("r")
#'
#' get_employment_to_population_ratio("grae")
#' }
get_employment_to_population_ratio <- function(by=NULL) {
params <- list(subject="lfpr")
if (!is.null(by)) params <- make_params(params, by, c("g", "r", "a", "e"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}

16
R/epi_query.r

@ -0,0 +1,16 @@
# Do the hard work of formatting the parameters and issuing the query
epi_query <- function(args) {
qs <- paste(sprintf("%s=%s", names(args), args), collapse="&")
httr::POST(
"http://www.epi.org/wp-admin/admin-ajax.php",
httr::add_headers(`X-Requested-With`="XMLHttpRequest"),
encode="form",
body=list(action="epi_getdata", queryString = qs)) -> res
httr::stop_for_status(res)
jsonlite::fromJSON(httr::content(res, as="text"), flatten=TRUE)
}

22
R/epidata-package.R

@ -0,0 +1,22 @@
#' A package to Tools to Retrieve Economic Policy Institute Data Library Extracts
#'
#' The Economic Policy Institute 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.
#'
#' @name epidata
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @importFrom purrr map map_df map_chr keep discard %||%
#' @importFrom stringi stri_replace_all_regex stri_trans_tolower %s+%
#' @importFrom dplyr %>% as_data_frame mutate_all
#' @import httr
#' @importFrom readr type_convert
#' @importFrom jsonlite fromJSON
#' @importFrom rvest html_text
#' @importFrom xml2 read_html
#' @importFrom tidyr gather
#' @importFrom stats setNames
NULL

283
R/gaps.r

@ -0,0 +1,283 @@
#' Retreive the percent by which hourly wages of female workers are less than hourly wages of male workers
#'
#' The gender wage gap is the percent by which hourly wages of female workers are less than
#' hourly wages of male workers. It is also often expressed as a wage ratio (women's
#' share of men's wages) by subtracting the gap from 100 percent.
#'
#' \itemize{
#' \item{A median gender wage gap of 17.3 percent means that a typical woman is paid 17.3
#' percent less per hour than a typical man.}
#' \item{An average gender wage gap of 19.7 percent means that on average women are paid
#' 19.7 percent less per hour than men.}
#' \item{A regression-based gender wage gap of 21.7 percent means that on average women
#' are paid 21.7 percent less per hour than men, all else held equal (controlling for
#' gender, race and ethnicity, education, experience, and geographic location).}
#' }
#'
#' @param by \code{NULL} or \code{r} for a parition by race
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_gender_wage_gap()
#'
#' get_gender_wage_gap("r")
#' }
get_gender_wage_gap <- function(by=NULL) {
params <- list(subject="wagegap-mf")
if (!is.null(by)) params <- make_params(params, by, c("r"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[\\(\\)]", "")
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the percent by which hourly wages of black workers are less than hourly wages of white workers
#'
#' The black-white wage gap is the percent by which hourly wages of black workers are less
#' than hourly wages of white workers. It is also often expressed as a wage ratio (black
#' workers' share of white workers' wages) by subtracting the gap from 100 percent.
#'
#' \itemize{
#' \item{A median black-white wage gap of 26.2 percent means that a typical black worker
#' is paid 26.2 percent less per hour than a typical white worker.}
#' \item{An average black-white wage gap of 26.6 percent means that on average black
#' workers are paid 26.6 percent less per hour than white workers.}
#' \item{A regression-based black-white wage gap of 15.2 percent means that on average
#' black workers are paid 15.2 percent less per hour than white workers, all else
#' held equal (controlling for gender, race and ethnicity, education, experience,
#' and geographic location).}
#' }
#'
#' @param by \code{NULL} or \code{g} for a parition by gender
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_black_white_wage_gap()
#'
#' get_black_white_wage_gap("g")
#' }
get_black_white_wage_gap <- function(by=NULL) {
params <- list(subject="wagegap-bw")
if (!is.null(by)) params <- make_params(params, by, c("g"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[\\(\\)]", "")
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the percent by which hourly wages of Hispanic workers are less than hourly wages of white workers
#'
#' The Hispanic-white wage gap is the percent by which hourly wages of Hispanic workers
#' are less than hourly wages of white workers. It is also often expressed as a wage ratio
#' (Hispanic workers' share of white workers' wages) by subtracting the gap from 100 percent.
#'
#' \itemize{
#' \item{A median Hispanic-white wage gap of 29.6 percent means that a typical Hispanic
#' worker is paid 29.6 percent less per hour than a typical white worker.}
#' \item{An average Hispanic-white wage gap of 30.1 percent means that on average Hispanic
#' workers are paid 30.1 percent less per hour than white workers.}
#' \item{A regression-based Hispanic-white wage gap of 11.1 percent means that on average
#' Hispanic workers are paid 11.1 percent less per hour than white workers, all
#' else held equal (controlling for gender, race and ethnicity, education,
#' experience, and geographic location).}
#' }
#'
#' @param by \code{NULL} or \code{g} for a parition by gender
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_hispanic_white_wage_gap()
#'
#' get_hispanic_white_wage_gap("g")
#' }
get_hispanic_white_wage_gap <- function(by=NULL) {
params <- list(subject="wagegap-hw")
if (!is.null(by)) params <- make_params(params, by, c("g"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[\\(\\)]", "")
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the percent by which hourly wages of college graduates exceed those of otherwise
#' equivalent high school graduates
#'
#' A regression-based college wage premium of 56.1 percent means that on average workers
#' with a college degree are paid 56.1 percent more per hour than workers whose highest
#' education credential is a high school diploma, all else held equal (controlling for
#' gender, race and ethnicity, education, experience, and geographic location).
#'
#' @param by \code{NULL} or \code{g} for a parition by gender
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_college_wage_premium()
#'
#' get_college_wage_premium("g")
#' }
get_college_wage_premium <- function(by=NULL) {
params <- list(subject="wagegap-coll")
if (!is.null(by)) params <- make_params(params, by, c("g"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[\\(\\)]", "")
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' 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
#'
#' A regression-based non-high school wage penalty of 21.8 percent means that on average
#' workers without a high school diploma are paid 21.8 percent less per hour than workers
#' with a high school diploma, all else held equal (controlling for gender, race and
#' ethnicity, education, experience, and geographic location).
#'
#' @param by \code{NULL} or \code{g} for a parition by gender
#' @return \code{tbl_df} with data filtered by the selected criteria.
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_non_high_school_wage_penalty()
#'
#' get_non_high_school_wage_penalty("g")
#' }
get_non_high_school_wage_penalty <- function(by=NULL) {
params <- list(subject="wagegap-hs")
if (!is.null(by)) params <- make_params(params, by, c("g"))
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[\\(\\)]", "")
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the level of inequality within the hourly wage distribution.
#'
#' The 95–50 and 50–10 wage ratios are representations of the level of inequality within
#' the hourly wage distribution. The larger the ratio, the greater the gap between the
#' top and the middle or the middle and the bottom of the wage distribution.
#'
#' \itemize{
#' \item{A 50–10 wage ratio of 1.91 means that workers at the 50th percentile of the wage
#' distribution are paid 1.91 times more per hour than the workers at the 10th percentile.}
#' \item{A 95–50 wage ratio of 3.28 means that workers at the 95th percentile of the wage
#' distribution are paid 3.28 times more per hour than the workers at the 50th percentile.}
#' }
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender) or
#' \code{r} (Race), i.e. if you want to retrieve
#' 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{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_wage_ratios()
#'
#' get_wage_ratios("r")
#'
#' get_wage_ratios("gr")
#' }
get_wage_ratios <- function(by=NULL) {
params <- list(preset="wage-ratios")
if (!is.null(by)) {
params <- make_params(params, by, c("g", "r"))
params <- c(params, list(subject="wage", d="10,50,95,5010,9550,mean"))
}
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}

23
R/utils.r

@ -0,0 +1,23 @@
make_params <- function(params, by, ok="") {
by <- stringi::stri_trans_tolower(by)
by <- stringi::stri_replace_all_regex(by, "[[:space:]]", "")
by <- strsplit(by, "")[[1]]
by <- purrr::keep(by, `%in%`, ok)
by <- sort(unique(by))
params <- c(params, setNames(as.list(rep("*", length(by))), by))
}
clean_cols <- function(x) {
if (any(grepl("%", x))) {
as.numeric(stringi::stri_replace_all_fixed(x, "%", ""))/100
} else if (any(grepl("\\$", x))) {
as.numeric(stringi::stri_replace_all_fixed(x, "$", ""))
} else {
x
}
}

136
R/wages.r

@ -0,0 +1,136 @@
#' Retreive the hourly wage in the middle of the wage distribution
#'
#' The median wage is the hourly wage in the middle of the wage distribution;
#' 50 percent of wage earners earn less and 50 percent earn more. The average wage is
#' the arithmetic mean of hourly wages; or, the sum of all workers' hourly wages divided
#' by the number of workers.
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender) or
#' \code{r} (Race), i.e. if you want to retrieve
#' 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{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_median_and_mean_wages()
#'
#' get_median_and_mean_wages("r")
#'
#' get_median_and_mean_wages("gr")
#' }
get_median_and_mean_wages <- function(by=NULL) {
params <- list(preset="wage-avg")
if (!is.null(by)) {
params <- make_params(params, by, c("g", "r"))
params <- c(params, list(subject="wage", d="50,mean"))
}
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive the average hourly wages of workers disaggregated by the highest level of education attained
#'
#' Wages by education are the average hourly wages of workers disaggregated by the highest
#' level of education attained. Employment shares provide the distribution of educational
#' attainment for workers of each gender, racial, and ethnic group as a share of total
#' employed for each group.
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender) or
#' \code{r} (Race), i.e. if you want to retrieve
#' 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{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_wages_by_education()
#'
#' get_wages_by_education("r")
#'
#' get_wages_by_education("gr")
#' }
get_wages_by_education <- function(by=NULL) {
params <- list(preset="wage-education")
if (!is.null(by)) {
params <- make_params(params, by, c("g", "r"))
params <- c(params, list(subject="wage", e="*", d="50,mean", m="share"))
}
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}
#' Retreive wages at ten distinct points in the wage distribution
#'
#' Wage percentiles are wages at ten distinct points in the wage distribution: deciles
#' and the 95th percentile. The 95–50 and 50–10 wage ratios show how much greater wages
#' are at the top than the middle, and at the middle than the bottom, respectively.
#'
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender) or
#' \code{r} (Race), i.e. if you want to retrieve
#' 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{http://www.epi.org/data/}{Economic Policy Institute Data Library}
#' @export
#' @examples \dontrun{
#' get_wages_by_percentile()
#'
#' get_wages_by_percentile("r")
#'
#' get_wages_by_percentile("gr")
#' }
get_wages_by_percentile <- function(by=NULL) {
params <- list(preset="wage-percentiles")
if (!is.null(by)) {
params <- make_params(params, by, c("g", "r"))
params <- c(params, list(subject="wage", d="*"))
}
res <- epi_query(params)
cols <- stringi::stri_trans_tolower(res$columns$name)
cols <- stringi::stri_replace_all_regex(cols, "[[:space:]" %s+%
rawToChar(as.raw(c(0xe2, 0x80, 0x93))) %s+% "-]+",
"_")
out <- setNames(as_data_frame(res$data), cols)
out <- dplyr::mutate_all(out, "clean_cols")
out <- suppressMessages(readr::type_convert(out))
cite <- html_text(read_html(res$meta$source %||% "<p>Economic Policy Institute</p>"))
message(sprintf('Note: %s\nCitation: "%s"', res$meta$notes %||% "None", cite))
out
}

75
README.Rmd

@ -0,0 +1,75 @@
---
output: rmarkdown::github_document
---
`epidata` : Tools to Retrieve Economic Policy Institute Data Library Extracts
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.
The following functions are implemented:
- `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_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_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_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_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_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_ratios`: Retreive the level of inequality within the hourly wage distribution.
### Installation
```{r eval=FALSE}
devtools::install_git("https://gitlab.com/hrbrmstr/epidata.git")
```
```{r message=FALSE, warning=FALSE, error=FALSE}
options(width=120)
```
### Usage
```{r message=FALSE, warning=FALSE, error=FALSE}
library(epidata)
# current verison
packageVersion("epidata")
get_black_white_wage_gap()
get_underemployment()
get_median_and_mean_wages("gr")
```
### Test Results
```{r message=FALSE, warning=FALSE, error=FALSE}
library(epidata)
library(testthat)
date()
test_dir("tests/")
```

124
README.md

@ -0,0 +1,124 @@
`epidata` : Tools to Retrieve Economic Policy Institute Data Library Extracts
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.
The following functions are implemented:
- `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_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_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_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_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_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_ratios`: Retreive the level of inequality within the hourly wage distribution.
### Installation
``` r
devtools::install_git("https://gitlab.com/hrbrmstr/epidata.git")
```
``` r
options(width=120)
```
### Usage
``` r
library(epidata)
# current verison
packageVersion("epidata")
```
## [1] '0.1.0'
``` r
get_black_white_wage_gap()
```
## # A tibble: 43 × 8
## date white_median white_average black_median black_average gap_median gap_average gap_regression_based
## <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1973 17.19 19.68 13.50 15.43 0.215 0.216 0.124
## 2 1974 16.73 19.22 13.34 15.19 0.203 0.210 0.105
## 3 1975 16.54 19.23 13.43 15.14 0.188 0.213 0.107
## 4 1976 16.73 19.39 13.45 15.74 0.196 0.188 0.089
## 5 1977 16.71 19.33 13.41 15.51 0.198 0.197 0.095
## 6 1978 16.72 19.43 13.38 15.72 0.200 0.191 0.092
## 7 1979 16.88 19.64 13.85 16.09 0.180 0.181 0.090
## 8 1980 16.58 19.23 13.50 15.73 0.185 0.182 0.092
## 9 1981 16.22 19.10 13.33 15.64 0.178 0.181 0.087
## 10 1982 16.47 19.26 13.17 15.45 0.200 0.198 0.103
## # ... with 33 more rows
``` r
get_underemployment()
```
## # A tibble: 416 × 2
## date all
## <date> <dbl>
## 1 1989-12-01 0.093
## 2 1990-01-01 0.093
## 3 1990-02-01 0.093
## 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 406 more rows
``` r
get_median_and_mean_wages("gr")
```
## # A tibble: 43 × 25
## date median average men_median men_average women_median women_average white_median white_average black_median
## <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1973 16.53 19.05 19.89 22.32 12.47 14.30 17.19 19.68 13.50
## 2 1974 16.17 18.67 19.63 21.89 12.39 14.04 16.73 19.22 13.34
## 3 1975 16.05 18.64 19.76 21.81 12.43 14.14 16.54 19.23 13.43
## 4 1976 16.15 18.87 19.41 22.05 12.56 14.53 16.73 19.39 13.45
## 5 1977 16.07 18.77 19.84 22.05 12.51 14.36 16.71 19.33 13.41
## 6 1978 16.36 18.83 20.04 22.18 12.56 14.44 16.72 19.43 13.38
## 7 1979 16.15 19.06 20.30 22.46 12.66 14.63 16.88 19.64 13.85
## 8 1980 16.07 18.66 19.98 22.00 12.60 14.46 16.58 19.23 13.50
## 9 1981 15.66 18.52 19.52 21.82 12.53 14.44 16.22 19.10 13.33
## 10 1982 15.75 18.65 19.30 21.96 12.61 14.68 16.47 19.26 13.17
## # ... with 33 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>
### Test Results
``` r
library(epidata)
library(testthat)
date()
```
## [1] "Wed Jan 4 16:18:51 2017"
``` r
test_dir("tests/")
```
## testthat results ========================================================================================================
## OK: 15 SKIPPED: 0 FAILED: 0
##
## DONE ===================================================================================================================
## Nice code.

21
epidata.Rproj

@ -0,0 +1,21 @@
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --resave-data
PackageRoxygenize: rd,collate,namespace

18
man/epidata.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/epidata-package.R
\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
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.
}
\author{
Bob Rudis (bob@rud.is)
}

42
man/get_black_white_wage_gap.Rd

@ -0,0 +1,42 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gaps.r
\name{get_black_white_wage_gap}
\alias{get_black_white_wage_gap}
\title{Retreive the percent by which hourly wages of black workers are less than hourly wages of white workers}
\usage{
get_black_white_wage_gap(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or \code{g} for a parition by gender}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
The black-white wage gap is the percent by which hourly wages of black workers are less
than hourly wages of white workers. It is also often expressed as a wage ratio (black
workers' share of white workers' wages) by subtracting the gap from 100 percent.
}
\details{
\itemize{
\item{A median black-white wage gap of 26.2 percent means that a typical black worker
is paid 26.2 percent less per hour than a typical white worker.}
\item{An average black-white wage gap of 26.6 percent means that on average black
workers are paid 26.6 percent less per hour than white workers.}
\item{A regression-based black-white wage gap of 15.2 percent means that on average
black workers are paid 15.2 percent less per hour than white workers, all else
held equal (controlling for gender, race and ethnicity, education, experience,
and geographic location).}
}
}
\examples{
\dontrun{
get_black_white_wage_gap()
get_black_white_wage_gap("g")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

32
man/get_college_wage_premium.Rd

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gaps.r
\name{get_college_wage_premium}
\alias{get_college_wage_premium}
\title{Retreive the percent by which hourly wages of college graduates exceed those of otherwise
equivalent high school graduates}
\usage{
get_college_wage_premium(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or \code{g} for a parition by gender}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
A regression-based college wage premium of 56.1 percent means that on average workers
with a college degree are paid 56.1 percent more per hour than workers whose highest
education credential is a high school diploma, all else held equal (controlling for
gender, race and ethnicity, education, experience, and geographic location).
}
\examples{
\dontrun{
get_college_wage_premium()
get_college_wage_premium("g")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

32
man/get_employment_to_population_ratio.Rd

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/employment.r
\name{get_employment_to_population_ratio}
\alias{get_employment_to_population_ratio}
\title{Retreive the share of the civilian noninstitutional population that is employed}
\usage{
get_employment_to_population_ratio(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender),
\code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
unemployment data by gender, race and education, you would set this parameter to "\code{gre}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
Retreive the share of the civilian noninstitutional population that is employed
}
\examples{
\dontrun{
get_employment_to_population_ratio()
get_employment_to_population_ratio("r")
get_employment_to_population_ratio("grae")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

41
man/get_gender_wage_gap.Rd

@ -0,0 +1,41 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gaps.r
\name{get_gender_wage_gap}
\alias{get_gender_wage_gap}
\title{Retreive the percent by which hourly wages of female workers are less than hourly wages of male workers}
\usage{
get_gender_wage_gap(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or \code{r} for a parition by race}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
The gender wage gap is the percent by which hourly wages of female workers are less than
hourly wages of male workers. It is also often expressed as a wage ratio (women's
share of men's wages) by subtracting the gap from 100 percent.
}
\details{
\itemize{
\item{A median gender wage gap of 17.3 percent means that a typical woman is paid 17.3
percent less per hour than a typical man.}
\item{An average gender wage gap of 19.7 percent means that on average women are paid
19.7 percent less per hour than men.}
\item{A regression-based gender wage gap of 21.7 percent means that on average women
are paid 21.7 percent less per hour than men, all else held equal (controlling for
gender, race and ethnicity, education, experience, and geographic location).}
}
}
\examples{
\dontrun{
get_gender_wage_gap()
get_gender_wage_gap("r")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

42
man/get_hispanic_white_wage_gap.Rd

@ -0,0 +1,42 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gaps.r
\name{get_hispanic_white_wage_gap}
\alias{get_hispanic_white_wage_gap}
\title{Retreive the percent by which hourly wages of Hispanic workers are less than hourly wages of white workers}
\usage{
get_hispanic_white_wage_gap(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or \code{g} for a parition by gender}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
The Hispanic-white wage gap is the percent by which hourly wages of Hispanic workers
are less than hourly wages of white workers. It is also often expressed as a wage ratio
(Hispanic workers' share of white workers' wages) by subtracting the gap from 100 percent.
}
\details{
\itemize{
\item{A median Hispanic-white wage gap of 29.6 percent means that a typical Hispanic
worker is paid 29.6 percent less per hour than a typical white worker.}
\item{An average Hispanic-white wage gap of 30.1 percent means that on average Hispanic
workers are paid 30.1 percent less per hour than white workers.}
\item{A regression-based Hispanic-white wage gap of 11.1 percent means that on average
Hispanic workers are paid 11.1 percent less per hour than white workers, all
else held equal (controlling for gender, race and ethnicity, education,
experience, and geographic location).}
}
}
\examples{
\dontrun{
get_hispanic_white_wage_gap()
get_hispanic_white_wage_gap("g")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

32
man/get_labor_force_participation_rate.Rd

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/employment.r
\name{get_labor_force_participation_rate}
\alias{get_labor_force_participation_rate}
\title{Retreive the share of the civilian noninstitutional population that is in the labor force}
\usage{
get_labor_force_participation_rate(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender),
\code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
unemployment data by gender, race and education, you would set this parameter to "\code{gre}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
(i.e., working or looking for work)
}
\examples{
\dontrun{
get_labor_force_participation_rate()
get_labor_force_participation_rate("r")
get_labor_force_participation_rate("grae")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

32
man/get_long_term_unemployment.Rd

@ -0,0 +1,32 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/employment.r
\name{get_long_term_unemployment}
\alias{get_long_term_unemployment}
\title{Retreive the share of the labor force that has been unemployed for six months or longer}
\usage{
get_long_term_unemployment(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender),
\code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
unemployment data by gender, race and education, you would set this parameter to "\code{gre}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
Retreive the share of the labor force that has been unemployed for six months or longer
}
\examples{
\dontrun{
get_long_term_unemployment()
get_long_term_unemployment("r")
get_long_term_unemployment("grae")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

35
man/get_median_and_mean_wages.Rd

@ -0,0 +1,35 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wages.r
\name{get_median_and_mean_wages}
\alias{get_median_and_mean_wages}
\title{Retreive the hourly wage in the middle of the wage distribution}
\usage{
get_median_and_mean_wages(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender) or
\code{r} (Race), i.e. if you want to retrieve
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.
}
\description{
The median wage is the hourly wage in the middle of the wage distribution;
50 percent of wage earners earn less and 50 percent earn more. The average wage is
the arithmetic mean of hourly wages; or, the sum of all workers' hourly wages divided
by the number of workers.
}
\examples{
\dontrun{
get_median_and_mean_wages()
get_median_and_mean_wages("r")
get_median_and_mean_wages("gr")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

33
man/get_non_high_school_wage_penalty.Rd

@ -0,0 +1,33 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gaps.r
\name{get_non_high_school_wage_penalty}
\alias{get_non_high_school_wage_penalty}
\title{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}
\usage{
get_non_high_school_wage_penalty(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or \code{g} for a parition by gender}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
A regression-based non-high school wage penalty of 21.8 percent means that on average
workers without a high school diploma are paid 21.8 percent less per hour than workers
with a high school diploma, all else held equal (controlling for gender, race and
ethnicity, education, experience, and geographic location).
}
\examples{
\dontrun{
get_non_high_school_wage_penalty()
get_non_high_school_wage_penalty("g")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

36
man/get_underemployment.Rd

@ -0,0 +1,36 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/employment.r
\name{get_underemployment}
\alias{get_underemployment}
\title{Retreive the share of the labor force that is "underemployed"}
\usage{
get_underemployment(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender),
\code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
unemployment data by gender, race and education, you would set this parameter to "\code{gre}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
Underemployment is the share of the labor force that either 1) is unemployed, 2) is
working part time but wants and is available to work full time (an "involuntary" part
timer), or 3) wants and is available to work and has looked for work in the last year
but has given up actively seeking work in the last four weeks ("marginally attached"
worker).
}
\examples{
\dontrun{
get_underemployment()
get_underemployment("r")
get_underemployment("grae")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

35
man/get_unemployment.Rd

@ -0,0 +1,35 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/employment.r
\name{get_unemployment}
\alias{get_unemployment}
\title{Retreive the share of the labor force without a job}
\usage{
get_unemployment(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender),
\code{r} (Race), \code{a} (Age), \code{e} (Education). i.e. if you want to retrieve
unemployment data by gender, race and education, you would set this parameter to "\code{gre}".}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
Retreive the share of the labor force without a job
}
\note{
See \code{get_unemployment_by_state()} for information on retrieving unemployment by state+race.
}
\examples{
\dontrun{
get_unemployment()
get_unemployment("r")
get_unemployment("grae")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

31
man/get_unemployment_by_state.Rd

@ -0,0 +1,31 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/employment.r
\name{get_unemployment_by_state}
\alias{get_unemployment_by_state}
\title{Retreive the share of the labor force without a job (by state)}
\usage{
get_unemployment_by_state(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or \code{r} for a partition by race.}
}
\value{
\code{tbl_df} with data filtered by the selected criteria.
}
\description{
Retreive the share of the labor force without a job (by state)
}
\note{
See \code{get_unemployment()} for other unemployment extracts..
}
\examples{
\dontrun{
get_unemployment_by_state()
get_unemployment_by_state("r")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

42
man/get_wage_ratios.Rd

@ -0,0 +1,42 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gaps.r
\name{get_wage_ratios}
\alias{get_wage_ratios}
\title{Retreive the level of inequality within the hourly wage distribution.}
\usage{
get_wage_ratios(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender) or
\code{r} (Race), i.e. if you want to retrieve
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.
}
\description{
The 95–50 and 50–10 wage ratios are representations of the level of inequality within
the hourly wage distribution. The larger the ratio, the greater the gap between the
top and the middle or the middle and the bottom of the wage distribution.
}
\details{
\itemize{
\item{A 50–10 wage ratio of 1.91 means that workers at the 50th percentile of the wage
distribution are paid 1.91 times more per hour than the workers at the 10th percentile.}
\item{A 95–50 wage ratio of 3.28 means that workers at the 95th percentile of the wage
distribution are paid 3.28 times more per hour than the workers at the 50th percentile.}
}
}
\examples{
\dontrun{
get_wage_ratios()
get_wage_ratios("r")
get_wage_ratios("gr")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

35
man/get_wages_by_education.Rd

@ -0,0 +1,35 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wages.r
\name{get_wages_by_education}
\alias{get_wages_by_education}
\title{Retreive the average hourly wages of workers disaggregated by the highest level of education attained}
\usage{
get_wages_by_education(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender) or
\code{r} (Race), i.e. if you want to retrieve
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.
}
\description{
Wages by education are the average hourly wages of workers disaggregated by the highest
level of education attained. Employment shares provide the distribution of educational
attainment for workers of each gender, racial, and ethnic group as a share of total
employed for each group.
}
\examples{
\dontrun{
get_wages_by_education()
get_wages_by_education("r")
get_wages_by_education("gr")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

34
man/get_wages_by_percentile.Rd

@ -0,0 +1,34 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wages.r
\name{get_wages_by_percentile}
\alias{get_wages_by_percentile}
\title{Retreive wages at ten distinct points in the wage distribution}
\usage{
get_wages_by_percentile(by = NULL)
}
\arguments{
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender) or
\code{r} (Race), i.e. if you want to retrieve
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.
}
\description{
Wage percentiles are wages at ten distinct points in the wage distribution: deciles
and the 95th percentile. The 95–50 and 50–10 wage ratios show how much greater wages
are at the top than the middle, and at the middle than the bottom, respectively.
}
\examples{
\dontrun{
get_wages_by_percentile()
get_wages_by_percentile("r")
get_wages_by_percentile("gr")
}
}
\references{
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library}
}

2
tests/test-all.R

@ -0,0 +1,2 @@
library(testthat)
test_check("epidata")

23
tests/testthat/test-epidata.R

@ -0,0 +1,23 @@
context("basic functionality")
test_that("we can do something", {
testthat::skip_on_cran()
testthat::skip_on_travis()
expect_that(get_black_white_wage_gap(), is_a("data.frame"))
expect_that(get_college_wage_premium(), 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_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_non_high_school_wage_penalty(), 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_wage_ratios(), is_a("data.frame"))
expect_that(get_wages_by_education(), is_a("data.frame"))
expect_that(get_wages_by_percentile(), is_a("data.frame"))
})
Loading…
Cancel
Save