~hrbrmstr/epidata

c52c08e1d2dd4680d3e234c37b0f2841a523c1b7 — boB Rudis 2 years ago 7e33830
Fix for CRAN ERRORs - moved to https API
7 files changed, 127 insertions(+), 122 deletions(-)

M DESCRIPTION
M NEWS.md
M R/epi_query.r
M README.Rmd
M README.md
A README_files/figure-gfm/unnamed-chunk-4-1.png
M cran-comments.md
M DESCRIPTION => DESCRIPTION +3 -3
@@ 1,8 1,8 @@
Package: epidata
Type: Package
Title: Tools to Retrieve Economic Policy Institute Data Library Extracts
Version: 0.1.0
Date: 2017-01-08
Version: 0.2.0
Date: 2018-03-29
Authors@R: c(person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")))
Maintainer: Bob Rudis <bob@rud.is>
Encoding: UTF-8


@@ 29,4 29,4 @@ Imports:
    tidyr,
    readr,
    stringi
RoxygenNote: 6.0.1
RoxygenNote: 6.0.1.9000

M NEWS.md => NEWS.md +1 -0
@@ 2,6 2,7 @@
* WIP
* Added new `get_` functions for new data sources provided by the EPI
* Fixed issues with different return values for some hidden API calls
* Updated to use new https

0.1.0 
* Passes CRAN checks

M R/epi_query.r => R/epi_query.r +1 -1
@@ 4,7 4,7 @@ epi_query <- function(args) {
  qs <- paste(sprintf("%s=%s", names(args), args), collapse="&")

  httr::POST(
    "http://www.epi.org/wp-admin/admin-ajax.php",
    "https://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

M README.Rmd => README.Rmd +15 -23
@@ 2,15 2,21 @@
output: rmarkdown::github_document
---

```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```

[![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
# 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.
## Description 

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.

## What's Inside The Tin?

The following functions are implemented:



@@ 45,17 51,13 @@ The following functions are implemented:
- `get_wage_decomposition`:  Retreive Wage Decomposition
- `get_wage_ratios`:	Retreive the level of inequality within the hourly wage distribution.

### Installation
## Installation

```{r eval=FALSE}
devtools::install_github("hrbrmstr/epidata")
```

```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```

### Usage
## Usage

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


@@ 70,7 72,7 @@ get_underemployment()
get_median_and_mean_wages("gr")
```

### Extended Example
## Extended Example

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


@@ 112,15 114,5 @@ ggplot(df, aes(rate, median)) +
       caption="Source: EPI analysis of Current Population Survey Outgoing Rotation Group microdata") +
  theme_ipsum_rc(grid="XY")
```

### Test Results

```{r message=FALSE, warning=FALSE, error=FALSE}
library(epidata)
library(testthat)

date()

test_dir("tests/")
```


M README.md => README.md +101 -87
@@ 1,40 1,73 @@

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

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.
Tools to Retrieve Economic Policy Institute Data Library Extracts

## Description

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.

## 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_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_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_pension_coverage`: Retreive Pension Coverage
-   `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_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.

### Installation
  - `get_annual_wages_and_work_hours`: Retreive CPS ASEC Annual Wages
    and Work Hours
  - `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_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_pension_coverage`: Retreive Pension Coverage
  - `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_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.

## Installation

``` r
devtools::install_github("hrbrmstr/epidata")
```

### Usage
## Usage

``` r
library(epidata)


@@ 49,63 82,63 @@ packageVersion("epidata")
get_black_white_wage_gap()
```

    ## # A tibble: 44 x 8
    ## # A tibble: 45 x 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.41         19.93        13.67         15.63      0.215       0.216                0.120
    ##  2  1974        16.94         19.46        13.51         15.38      0.203       0.210                0.107
    ##  3  1975        16.75         19.47        13.60         15.33      0.188       0.213                0.105
    ##  4  1976        16.94         19.63        13.62         15.94      0.196       0.188                0.089
    ##  5  1977        16.93         19.57        13.58         15.71      0.198       0.197                0.094
    ##  6  1978        16.93         19.68        13.55         15.92      0.200       0.191                0.092
    ##  7  1979        17.10         19.89        14.02         16.29      0.180       0.181                0.090
    ##  8  1980        16.79         19.47        13.67         15.93      0.185       0.182                0.092
    ##  9  1981        16.42         19.34        13.50         15.84      0.178       0.181                0.087
    ## 10  1982        16.68         19.51        13.34         15.65      0.200       0.198                0.103
    ## # ... with 34 more rows
    ##  1  1973         17.8          20.4         14.1          16.0      0.211       0.213               0.114 
    ##  2  1974         17.4          19.9         13.8          15.7      0.204       0.211               0.103 
    ##  3  1975         17.3          20.0         14.0          15.8      0.187       0.211               0.100 
    ##  4  1976         17.3          20.0         13.9          16.3      0.195       0.188               0.0850
    ##  5  1977         17.5          20.1         14.0          16.2      0.195       0.195               0.0890
    ##  6  1978         17.3          20.1         13.8          16.3      0.200       0.191               0.0880
    ##  7  1979         17.5          20.3         14.3          16.6      0.180       0.181               0.0860
    ##  8  1980         17.2          19.9         14.0          16.3      0.185       0.182               0.0890
    ##  9  1981         16.8          19.7         13.8          16.2      0.178       0.181               0.0830
    ## 10  1982         17.0          19.9         13.6          16.0      0.200       0.198               0.100 
    ## # ... with 35 more rows

``` r
get_underemployment()
```

    ## # A tibble: 325 x 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
    ##    date          all
    ##    <date>      <dbl>
    ##  1 1989-12-01 0.0930
    ##  2 1990-01-01 0.0930
    ##  3 1990-02-01 0.0930
    ##  4 1990-03-01 0.0940
    ##  5 1990-04-01 0.0940
    ##  6 1990-05-01 0.0940
    ##  7 1990-06-01 0.0940
    ##  8 1990-07-01 0.0940
    ##  9 1990-08-01 0.0950
    ## 10 1990-09-01 0.0950
    ## # ... with 315 more rows

``` r
get_median_and_mean_wages("gr")
```

    ## # A tibble: 44 x 25
    ## # A tibble: 45 x 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.74   19.30      20.14       22.60        12.63         14.48        17.41         19.93        13.67
    ##  2  1974  16.37   18.91      19.88       22.17        12.54         14.22        16.94         19.46        13.51
    ##  3  1975  16.26   18.87      20.01       22.09        12.59         14.32        16.75         19.47        13.60
    ##  4  1976  16.36   19.11      19.65       22.33        12.72         14.71        16.94         19.63        13.62
    ##  5  1977  16.28   19.00      20.09       22.33        12.66         14.54        16.93         19.57        13.58
    ##  6  1978  16.57   19.07      20.29       22.46        12.72         14.62        16.93         19.68        13.55
    ##  7  1979  16.36   19.30      20.55       22.75        12.82         14.82        17.10         19.89        14.02
    ##  8  1980  16.28   18.89      20.24       22.28        12.76         14.65        16.79         19.47        13.67
    ##  9  1981  15.85   18.75      19.77       22.09        12.69         14.62        16.42         19.34        13.50
    ## 10  1982  15.95   18.89      19.54       22.24        12.76         14.87        16.68         19.51        13.34
    ## # ... with 34 more rows, and 15 more variables: black_average <dbl>, hispanic_median <dbl>, hispanic_average <dbl>,
    ##  1  1973   17.2    19.8       20.6        23.1         12.9          14.8         17.8          20.4         14.1
    ##  2  1974   16.8    19.4       20.3        22.7         12.9          14.6         17.4          19.9         13.8
    ##  3  1975   16.7    19.4       20.5        22.7         13.0          14.7         17.3          20.0         14.0
    ##  4  1976   16.7    19.5       20.1        22.8         13.0          15.0         17.3          20.0         13.9
    ##  5  1977   16.8    19.5       20.7        23.0         13.0          14.9         17.5          20.1         14.0
    ##  6  1978   16.9    19.5       20.7        22.9         13.0          14.9         17.3          20.1         13.8
    ##  7  1979   16.7    19.7       21.0        23.2         13.1          15.1         17.5          20.3         14.3
    ##  8  1980   16.6    19.3       20.7        22.8         13.0          15.0         17.2          19.9         14.0
    ##  9  1981   16.2    19.1       20.2        22.6         13.0          14.9         16.8          19.7         13.8
    ## 10  1982   16.3    19.3       20.0        22.7         13.0          15.2         17.0          19.9         13.6
    ## # ... with 35 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>

### Extended Example
## Extended Example

``` r
library(tidyverse)


@@ 119,11 152,11 @@ wages <- get_median_and_mean_wages()
glimpse(wages)
```

    ## Observations: 44
    ## Observations: 45
    ## Variables: 3
    ## $ date    <int> 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 198...
    ## $ median  <dbl> 16.74, 16.37, 16.26, 16.36, 16.28, 16.57, 16.36, 16.28, 15.85, 15.95, 15.91, 15.91, 16.00, 16.47, 1...
    ## $ average <dbl> 19.30, 18.91, 18.87, 19.11, 19.00, 19.07, 19.30, 18.89, 18.75, 18.89, 18.91, 18.99, 19.20, 19.66, 1...
    ## $ median  <dbl> 17.16, 16.78, 16.73, 16.70, 16.76, 16.92, 16.71, 16.63, 16.18, 16.28, 16.26, 16.24, 16.34, 16.81, 1...
    ## $ average <dbl> 19.75, 19.36, 19.39, 19.51, 19.52, 19.47, 19.72, 19.31, 19.14, 19.29, 19.31, 19.38, 19.61, 20.06, 2...

``` r
glimpse(unemployment)


@@ 163,24 196,5 @@ ggplot(df, aes(rate, median)) +
  theme_ipsum_rc(grid="XY")
```

<img src="README_files/figure-markdown_github-ascii_identifiers/unnamed-chunk-4-1.png" width="960" />

### Test Results

``` r
library(epidata)
library(testthat)

date()
```

    ## [1] "Tue Aug  1 18:06:05 2017"

``` r
test_dir("tests/")
```

    ## testthat results ========================================================================================================
    ## OK: 21 SKIPPED: 0 FAILED: 0
    ## 
    ## DONE ===================================================================================================================
<img src="README_files/figure-gfm/unnamed-chunk-4-1.png" width="960" />
\`\`\`

A README_files/figure-gfm/unnamed-chunk-4-1.png => README_files/figure-gfm/unnamed-chunk-4-1.png +0 -0

M cran-comments.md => cran-comments.md +6 -8
@@ 1,6 1,6 @@
## Test environments

* local OS X install, R 3.3.2, R-release
* local OS X install, R 3.4.4
* ubuntu 12.04 (on travis-ci), R-oldrel, R-devel, R-release
* win-builder (devel and release)



@@ 8,7 8,7 @@

0 errors | 0 warnings | 0 notes

* This is a new release.
* This is a bugfix release.

## Reverse dependencies



@@ 16,9 16,7 @@ This is a new release, so there are no reverse dependencies.

---

- Modified DESCRIPTION as per Kurt's submission feedback.

- examples and tests hit a live server but they httr::stop_on_status() on error and
  they run under the CRAN time limit for tests. If you'd rather they be in a 
  \dontrun{} block or just not run or tested on CRAN that's cool and I'll modify
  and re-submit.
- Big #ty to Kurt for reaching out. EPI changed their API endpoint
  to https which caused the error. This has been fixed.
- Also added a few new API endpoints and updated others to account for
  new fields being available.
\ No newline at end of file