boB Rudis
7 years ago
38 changed files with 539 additions and 76 deletions
@ -1,5 +1,9 @@ |
|||
0.1.0 |
|||
0.2.0 |
|||
* WIP |
|||
* Added new `get_` functions for new data sources provided by the EPI |
|||
* Fixed issues with different return values for some hidden API calls |
|||
|
|||
0.1.0 |
|||
* Passes CRAN checks |
|||
* Complete EPI SWADL hidden API coverage |
|||
* Initial release |
|||
|
@ -0,0 +1,47 @@ |
|||
#' Retreive Health Insurance Coverage |
|||
#' |
|||
#' Employer-sponsored health insurance (ESI) coverage shows the share of workers who |
|||
#' received health insurance from their own job for which their employer paid for at |
|||
#' least some of their health insurance coverage. |
|||
#' |
|||
#' Population sample: Private-sector workers age 18–64 & at least 20 hours/week and 26 weeks/year |
|||
#' |
|||
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender), |
|||
#' \code{r} (Race), \code{e} (Education), \code{d} (Percentile), \code{l} (Entry-level) |
|||
#' 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} |
|||
#' @note Data source: CPS ASEC |
|||
#' @export |
|||
#' @examples |
|||
#' get_health_insurance_coverage() |
|||
#' |
|||
#' get_health_insurance_coverage("r") |
|||
#' |
|||
#' get_health_insurance_coverage("gr") |
|||
get_health_insurance_coverage <- function(by=NULL) { |
|||
|
|||
params <- list(subject="healthcov") |
|||
|
|||
if (!is.null(by)) { |
|||
params <- make_params(params, by, c("g", "r", "e", "d", "l")) |
|||
} |
|||
names(params) <- gsub("^l$", "el", names(params)) |
|||
|
|||
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 |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
#' Retreive Pension Coverage |
|||
#' |
|||
#' Employer-provided pension coverage shows the share of workers included in an |
|||
#' employer-provided plan for which the employer paid for at least some of their pension |
|||
#' coverage. |
|||
#' |
|||
#' Population sample: Private-sector workers age 18–64 & at least 20 hours/week and 26 weeks/year |
|||
#' |
|||
#' @param by \code{NULL} or character string with any combination of \code{g} (Gender), |
|||
#' \code{r} (Race), \code{e} (Education), \code{d} (Percentile), \code{l} (Entry-level) |
|||
#' i.e. if you want to retrieve pension 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} |
|||
#' @note Data source: CPS ASEC |
|||
#' @export |
|||
#' @examples |
|||
#' get_health_insurance_coverage() |
|||
#' |
|||
#' get_health_insurance_coverage("r") |
|||
#' |
|||
#' get_health_insurance_coverage("gr") |
|||
get_pension_coverage <- function(by=NULL) { |
|||
|
|||
params <- list(subject="pensioncov") |
|||
|
|||
if (!is.null(by)) { |
|||
params <- make_params(params, by, c("g", "r", "e", "d", "l")) |
|||
} |
|||
names(params) <- gsub("^l$", "el", names(params)) |
|||
|
|||
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 |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
#' Retreive Productivity and hourly compensation |
|||
#' |
|||
#' Productivity is how much workers produce per hour, or the growth of output of goods and |
|||
#' services minus depreciation per hour worked. Compensation is made up of both nonwage |
|||
#' payments and wages. |
|||
#' |
|||
#' Wages are in 2015 dollars. Median compensation is calculated using hourly wage medians |
|||
#' from the CPS ORG and compensation from NIPA. |
|||
#' |
|||
#' Population sample: All workers & Production and nonsupervisory workers |
|||
#' |
|||
#' @param by \code{NULL} or character string of \code{g} (Gender) |
|||
#' @return \code{tbl_df} with data filtered by the selected criteria. |
|||
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
#' @note Data source: NIPA (compensation) | BLS Productivity Data |
|||
#' @export |
|||
#' @examples |
|||
#' get_productivity_and_hourly_compensation() |
|||
#' |
|||
#' get_productivity_and_hourly_compensation("g") |
|||
get_productivity_and_hourly_compensation <- function(by=NULL) { |
|||
|
|||
params <- list(subject="prodpay") |
|||
|
|||
if (!is.null(by)) { |
|||
params <- make_params(params, by, "g") |
|||
} |
|||
|
|||
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 |
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
#' Retreive Union Coverage |
|||
#' |
|||
#' The union coverage rate shows the percentage of the workforce covered by a collective |
|||
#' bargaining agreement. |
|||
#' |
|||
#' @return \code{tbl_df} |
|||
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
#' @note Data source: CPS ORG | Hirsch and Macpherson (2003) |
|||
#' @export |
|||
#' @examples |
|||
#' get_union_coverage() |
|||
get_union_coverage <- function() { |
|||
|
|||
params <- list(subject="unioncov") |
|||
|
|||
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 |
|||
|
|||
} |
@ -0,0 +1,42 @@ |
|||
#' Retreive Wage Decomposition |
|||
#' |
|||
#' Wage inequality data shows the overall wage inequality and the within-group and |
|||
#' between-group wage inequality over time. These measures allow an examination of how |
|||
#' much of the change in overall wage inequality in particular periods was due to changes |
|||
#' in within-group and between-group wage inequality. |
|||
#' |
|||
#' Population sample: Wage and salary workers age 18–64 |
|||
#' |
|||
#' @param by \code{NULL} or character string of \code{g} (Gender) |
|||
#' @return \code{tbl_df} with data filtered by the selected criteria. |
|||
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
#' @note Data source: CPS ORG |
|||
#' @export |
|||
#' @examples |
|||
#' get_wages_by_percentile() |
|||
#' |
|||
#' get_wages_by_percentile("g") |
|||
get_wage_decomposition <- function(by=NULL) { |
|||
|
|||
params <- list(subject="wageineq") |
|||
|
|||
if (!is.null(by)) { |
|||
params <- make_params(params, by, "g") |
|||
} |
|||
|
|||
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 |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
#' Retreive CPS ASEC Annual Wages and Work Hours |
|||
#' |
|||
#' Annual, weekly, and hourly wages and work hours show the average wages and work hours |
|||
#' of wage and salary workers using data from the CPS ASEC (also known as the March CPS). |
|||
#' Note that this data is not directly comparable to the CPS ORG data in median/average |
|||
#' hourly wage. |
|||
#' |
|||
#' @return \code{tbl_df} |
|||
#' @references \href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
#' @note CPS ASEC | Murphy and Welch (1989) |
|||
#' @export |
|||
#' @examples |
|||
#' get_annual_wages_and_work_hours() |
|||
get_annual_wages_and_work_hours <- function() { |
|||
|
|||
params <- list(subject="hours") |
|||
|
|||
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 |
|||
|
|||
} |
After Width: | Height: | Size: 282 KiB |
@ -0,0 +1,26 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/wages_and_hours.r |
|||
\name{get_annual_wages_and_work_hours} |
|||
\alias{get_annual_wages_and_work_hours} |
|||
\title{Retreive CPS ASEC Annual Wages and Work Hours} |
|||
\usage{ |
|||
get_annual_wages_and_work_hours() |
|||
} |
|||
\value{ |
|||
\code{tbl_df} |
|||
} |
|||
\description{ |
|||
Annual, weekly, and hourly wages and work hours show the average wages and work hours |
|||
of wage and salary workers using data from the CPS ASEC (also known as the March CPS). |
|||
Note that this data is not directly comparable to the CPS ORG data in median/average |
|||
hourly wage. |
|||
} |
|||
\note{ |
|||
CPS ASEC | Murphy and Welch (1989) |
|||
} |
|||
\examples{ |
|||
get_annual_wages_and_work_hours() |
|||
} |
|||
\references{ |
|||
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
} |
@ -0,0 +1,38 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/health.r |
|||
\name{get_health_insurance_coverage} |
|||
\alias{get_health_insurance_coverage} |
|||
\title{Retreive Health Insurance Coverage} |
|||
\usage{ |
|||
get_health_insurance_coverage(by = NULL) |
|||
} |
|||
\arguments{ |
|||
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender), |
|||
\code{r} (Race), \code{e} (Education), \code{d} (Percentile), \code{l} (Entry-level) |
|||
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{ |
|||
Employer-sponsored health insurance (ESI) coverage shows the share of workers who |
|||
received health insurance from their own job for which their employer paid for at |
|||
least some of their health insurance coverage. |
|||
} |
|||
\details{ |
|||
Population sample: Private-sector workers age 18–64 & at least 20 hours/week and 26 weeks/year |
|||
} |
|||
\note{ |
|||
Data source: CPS ASEC |
|||
} |
|||
\examples{ |
|||
get_health_insurance_coverage() |
|||
|
|||
get_health_insurance_coverage("r") |
|||
|
|||
get_health_insurance_coverage("gr") |
|||
} |
|||
\references{ |
|||
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
} |
@ -0,0 +1,38 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/pension.r |
|||
\name{get_pension_coverage} |
|||
\alias{get_pension_coverage} |
|||
\title{Retreive Pension Coverage} |
|||
\usage{ |
|||
get_pension_coverage(by = NULL) |
|||
} |
|||
\arguments{ |
|||
\item{by}{\code{NULL} or character string with any combination of \code{g} (Gender), |
|||
\code{r} (Race), \code{e} (Education), \code{d} (Percentile), \code{l} (Entry-level) |
|||
i.e. if you want to retrieve pension 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{ |
|||
Employer-provided pension coverage shows the share of workers included in an |
|||
employer-provided plan for which the employer paid for at least some of their pension |
|||
coverage. |
|||
} |
|||
\details{ |
|||
Population sample: Private-sector workers age 18–64 & at least 20 hours/week and 26 weeks/year |
|||
} |
|||
\note{ |
|||
Data source: CPS ASEC |
|||
} |
|||
\examples{ |
|||
get_health_insurance_coverage() |
|||
|
|||
get_health_insurance_coverage("r") |
|||
|
|||
get_health_insurance_coverage("gr") |
|||
} |
|||
\references{ |
|||
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
} |
@ -0,0 +1,36 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/productivity.r |
|||
\name{get_productivity_and_hourly_compensation} |
|||
\alias{get_productivity_and_hourly_compensation} |
|||
\title{Retreive Productivity and hourly compensation} |
|||
\usage{ |
|||
get_productivity_and_hourly_compensation(by = NULL) |
|||
} |
|||
\arguments{ |
|||
\item{by}{\code{NULL} or character string of \code{g} (Gender)} |
|||
} |
|||
\value{ |
|||
\code{tbl_df} with data filtered by the selected criteria. |
|||
} |
|||
\description{ |
|||
Productivity is how much workers produce per hour, or the growth of output of goods and |
|||
services minus depreciation per hour worked. Compensation is made up of both nonwage |
|||
payments and wages. |
|||
} |
|||
\details{ |
|||
Wages are in 2015 dollars. Median compensation is calculated using hourly wage medians |
|||
from the CPS ORG and compensation from NIPA. |
|||
|
|||
Population sample: All workers & Production and nonsupervisory workers |
|||
} |
|||
\note{ |
|||
Data source: NIPA (compensation) | BLS Productivity Data |
|||
} |
|||
\examples{ |
|||
get_productivity_and_hourly_compensation() |
|||
|
|||
get_productivity_and_hourly_compensation("g") |
|||
} |
|||
\references{ |
|||
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
} |
@ -0,0 +1,24 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/union.r |
|||
\name{get_union_coverage} |
|||
\alias{get_union_coverage} |
|||
\title{Retreive Union Coverage} |
|||
\usage{ |
|||
get_union_coverage() |
|||
} |
|||
\value{ |
|||
\code{tbl_df} |
|||
} |
|||
\description{ |
|||
The union coverage rate shows the percentage of the workforce covered by a collective |
|||
bargaining agreement. |
|||
} |
|||
\note{ |
|||
Data source: CPS ORG | Hirsch and Macpherson (2003) |
|||
} |
|||
\examples{ |
|||
get_union_coverage() |
|||
} |
|||
\references{ |
|||
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
} |
@ -0,0 +1,34 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/wage_decomposition.r |
|||
\name{get_wage_decomposition} |
|||
\alias{get_wage_decomposition} |
|||
\title{Retreive Wage Decomposition} |
|||
\usage{ |
|||
get_wage_decomposition(by = NULL) |
|||
} |
|||
\arguments{ |
|||
\item{by}{\code{NULL} or character string of \code{g} (Gender)} |
|||
} |
|||
\value{ |
|||
\code{tbl_df} with data filtered by the selected criteria. |
|||
} |
|||
\description{ |
|||
Wage inequality data shows the overall wage inequality and the within-group and |
|||
between-group wage inequality over time. These measures allow an examination of how |
|||
much of the change in overall wage inequality in particular periods was due to changes |
|||
in within-group and between-group wage inequality. |
|||
} |
|||
\details{ |
|||
Population sample: Wage and salary workers age 18–64 |
|||
} |
|||
\note{ |
|||
Data source: CPS ORG |
|||
} |
|||
\examples{ |
|||
get_wages_by_percentile() |
|||
|
|||
get_wages_by_percentile("g") |
|||
} |
|||
\references{ |
|||
\href{http://www.epi.org/data/}{Economic Policy Institute Data Library} |
|||
} |
Loading…
Reference in new issue