Despite being in cybersecurity nigh forever (a career that quickly turns one into a determined skeptic if you’re doing your job correctly) I have often trusted various (not to be named) news sources, reports and data sources to provide honest and as-unbiased-as-possible information. The debacle in the U.S. in late 2016 has proven (to me) that we’re all on our own when it comes to validating posited truth/fact. I’m teaching two data science college courses this Spring and one motivation for teaching is helping others on the path to data literacy so they don’t have to just believe what’s tossed at them.
It’s also one of the reasons I write R packages and blog/speak (when I can).
Today, I saw a chart in a WSJ article on the impending minimum wage changes (paywalled, so do the Google hack to read it) set to take effect in 19 states.
It’s a great chart and they cite the data source as coming from the Economic Policy Institute. I found some minimum wage data there and manually went through a bit of it to get enough of a feel that the WSJ wasn’t “mis-truthing” or truth-spinning. (As an aside, the minimum wage should definitely be higher, indexed and adjusted for inflation, but that’s a discussion for another time.)
While on EPI’s site, I did notice they had a “State of Working America Data Library” @ http://www.epi.org/data/. The data there is based on U.S. government published data and I validated that EPI isn’t fabricating anything (but you should not just take my word for it and do your own math from U.S. gov sources). I also noticed that the filtering interactions were delayed a bit and posited said condition was due to the site making AJAX/XHR calls to retrieve data. So, I peeked under the covers and discovered a robust, consistent, hidden API that is now wrapped in an R package dubbed
You can get the details of what’s available via the EPI site or through package docs.
What can you do with this data?
They seem to update the data (pretty much) monthly and it’s based on U.S. gov publications, so you can very easily validate “news” reports, potentially even easier than via packages that wrap the Bureau of Labor Statistics (BLS) API. On a lark, I wanted to compare the unemployment rate vs median wage over time (mostly to test the API and make a connected scatterplot). If you didn’t add the level of detail to the aesthetics I did, the following code is pretty small to do just that:
library(tidyverse) library(epidata) library(ggrepel) unemployment <- get_unemployment() wages <- get_median_and_mean_wages() glimpse(wages) ## Observations: 43 ## Variables: 3 ## $ date
1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, ... ## $ median 16.53, 16.17, 16.05, 16.15, 16.07, 16.36, 16.15, 16.07... ## $ average 19.05, 18.67, 18.64, 18.87, 18.77, 18.83, 19.06, 18.66... glimpse(unemployment) ## Observations: 456 ## Variables: 2 ## $ date 1978-12-01, 1979-01-01, 1979-02-01, 1979-03-01, 1979-04-... ## $ all 0.061, 0.061, 0.060, 0.060, 0.059, 0.059, 0.059, 0.058, 0... group_by(unemployment, date=as.integer(lubridate::year(date))) %>% summarise(rate=mean(all)) %>% left_join(select(wages, date, median), by="date") %>% filter(!is.na(median)) %>% arrange(date) -> df cols <- ggthemes::tableau_color_pal()(3) ggplot(df, aes(rate, median)) + geom_path(color=cols, arrow=arrow(type="closed", length=unit(10, "points"))) + geom_point() + geom_label_repel(aes(label=date), alpha=c(1, rep((4/5), (nrow(df)-2)), 1), size=c(5, rep(3, (nrow(df)-2)), 5), color=c(cols, rep("#2b2b2b", (nrow(df)-2)), cols), family="Hind Medium") + scale_x_continuous(name="Unemployment Rate", expand=c(0,0.001), label=scales::percent) + scale_y_continuous(name="Median Wage", expand=c(0,0.25), label=scales::dollar) + labs(title="U.S. Unemployment Rate vs Median Wage Since 1978", subtitle="Wage data is in 2015 USD", caption="Source: EPI analysis of Current Population Survey Outgoing Rotation Group microdata") + hrbrmisc::theme_hrbrmstr(grid="XY")
You can build your own “State of Working America Data Library” dashboard with this data (with
shiny) and be a bit of a citizen journalist, keeping the actual media in check and staying more informed an engaged.
As usual, drop issues & feature requests in the github repo. If you make some fun things with the data, drop a comment in the blog. Unless something major comes up the package should be on CRAN by the weekend.