<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/putting-it-all-together/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rud.is/b/2017/02/18/putting-it-all-together/"> R – rud.is</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The kind folks over at <a target="_blank" rel="nofollow" href="http://twitter.com/RStudio">@RStudio</a> <a target="_blank" rel="nofollow" href="https://www.rstudio.com/rviews/2017/02/17/january-new-data-packages/">gave a nod</a> to my recently CRAN-released <a target="_blank" rel="nofollow" href="https://github.com/hrbrmstr/epidata"><code>epidata</code></a> package in their January data package roundup and I thought it might be useful to give it one more showcase using the recent CRAN update to <a target="_blank" rel="nofollow" href="https://github.com/hrbrmstr/ggalt"><code>ggalt</code></a> and the new <a target="_blank" rel="nofollow" href="https://github.com/hrbrmstr/hrbrthemes"><code>hrbrthemes</code></a> (github-only for now) packages.</p>
<h3>Labor force participation rate</h3>
<p>The U.S. labor force participation rate (LFPR) is an oft-overlooked and under- or mis-reported economic indicator. I’ll borrow the definition from Investopedia:</p>
<div>
The participation rate is a measure of the active portion of an economy’s labor force. It refers to the number of people who are either employed or are actively looking for work. During an economic recession, many workers often get discouraged and stop looking for employment, resulting in a decrease in the participation rate.
</div>
<p>Population age distributions and other factors are necessary to honestly interpret this statistic. Parties in power usually dismiss/ignore this statistic outright and their opponents tend to wholly embrace it for criticism (it’s an easy target if you’re naive). “Yay” partisan democracy.</p>
<p>Since the LFPR is has nuances when looked at categorically, let’s take a look at it by attained education level to see how that particular view has changed over time (at least since the gov-quants have been tracking it).</p>
<p>We can easily grab this data with <code>epidata::get_labor_force_participation_rate()</code>(and, we’ll setup some <code>library()</code> calls while we’re at it:</p>
<pre><code>library(epidata)
library(hrbrthemes) # devtools::install_github(&quot;hrbrmstr/hrbrthemes&quot;)
library(ggalt)
library(tidyverse)
library(stringi)

part_rate &lt;- get_labor_force_participation_rate(&quot;e&quot;)

glimpse(part_rate)
## Observations: 457
## Variables: 7
## $ date              &lt;date> 1978-12-01, 1979-01-01, 1979-02-01, 1979-03-01, 1979-04-01, 1979-05-01...
## $ all               &lt;dbl> 0.634, 0.634, 0.635, 0.636, 0.636, 0.637, 0.637, 0.637, 0.638, 0.638, 0...
## $ less_than_hs      &lt;dbl> 0.474, 0.475, 0.475, 0.475, 0.475, 0.474, 0.474, 0.473, 0.473, 0.473, 0...
## $ high_school       &lt;dbl> 0.690, 0.691, 0.692, 0.692, 0.693, 0.693, 0.694, 0.694, 0.695, 0.696, 0...
## $ some_college      &lt;dbl> 0.709, 0.710, 0.711, 0.712, 0.712, 0.713, 0.712, 0.712, 0.712, 0.712, 0...
## $ bachelor's_degree &lt;dbl> 0.771, 0.772, 0.772, 0.773, 0.772, 0.772, 0.772, 0.772, 0.772, 0.773, 0...
## $ advanced_degree   &lt;dbl> 0.847, 0.847, 0.848, 0.848, 0.848, 0.848, 0.847, 0.847, 0.848, 0.848, 0...</code></pre>
<p>One of the easiest things to do is to use <code>ggplot2</code> to make a faceted line chart by attained education level. But, let’s change the labels so they are a bit easier on the eyes in the facets and switch the facet order from alphabetical to something more useful:</p>
<pre><code>gather(part_rate, category, rate, -date) %>% 
  mutate(category=stri_replace_all_fixed(category, &quot;_&quot;, &quot; &quot;),
         category=stri_trans_totitle(category),
         category=stri_replace_last_regex(category, &quot;Hs$&quot;, &quot;High School&quot;),
         category=factor(category, levels=c(&quot;Advanced Degree&quot;, &quot;Bachelor's Degree&quot;, &quot;Some College&quot;, 
                                            &quot;High School&quot;, &quot;Less Than High School&quot;, &quot;All&quot;)))  -> part_rate</code></pre>
<p>Now, we’ll make a simple line chart, tweaking the aesthetics just a bit:</p>
<pre><code>ggplot(part_rate) +
  geom_line(aes(date, rate, group=category)) +
  scale_y_percent(limits=c(0.3, 0.9)) +
  facet_wrap(~category, scales=&quot;free&quot;) +
  labs(x=paste(format(range(part_rate$date), &quot;%Y-%b&quot;), collapse=&quot; to &quot;), 
       y=&quot;Participation rate (%)&quot;, 
       title=&quot;U.S. Labor Force Participation Rate&quot;,
       caption=&quot;Source: EPI analysis of basic monthly Current Population Survey microdata.&quot;) +
  theme_ipsum_rc(grid=&quot;XY&quot;, axis=&quot;XY&quot;)</code></pre>
<p><img alt="" class="wp-image-5069" src="https://i2.wp.com/rud.is/b/wp-content/uploads/2017/02/RStudio-2.png?resize=780%2C424&ssl=1" data-recalc-dims="1"></p>
<p>The “All” view is interesting in that the LFPR has held fairly “steady” between 60% &amp; 70%. Those individual and fractional percentage points actually translate to real humans, so the “minor” fluctuations do matter. </p>
<p>It’s also interesting to see the direct contrast between the starting historical rate and current rate (you could also do the same with min/max rates, etc.) We can use a “dumbbell” chart to compare the 1978 value to today’s value, but we’ll need to reshape the data a bit first:</p>
<pre><code>group_by(part_rate, category) %>% 
  arrange(date) %>% 
  slice(c(1, n())) %>% 
  spread(date, rate) %>% 
  ungroup() %>% 
  filter(category != &quot;All&quot;) %>% 
  mutate(category=factor(category, levels=rev(levels(category)))) -> rate_range

filter(part_rate, category==&quot;Advanced Degree&quot;) %>% 
  arrange(date) %>% 
  slice(c(1, n())) %>% 
  mutate(lab=lubridate::year(date)) -> lab_df</code></pre>
<p>(We’ll be using the extra data frame to add labels the chart.)</p>
<p>Now, we can compare the various ranges, once again tweaking aesthetics a bit:</p>
<pre><code>ggplot(rate_range) +
  geom_dumbbell(aes(y=category, x=`1978-12-01`, xend=`2016-12-01`),
                size=3, color=&quot;#e3e2e1&quot;,
                colour_x = &quot;#5b8124&quot;, colour_xend = &quot;#bad744&quot;,
                dot_guide=TRUE, dot_guide_size=0.25) +
  geom_text(data=lab_df, aes(x=rate, y=5.25, label=lab), vjust=0) +
  scale_x_percent(limits=c(0.375, 0.9)) +
  labs(x=NULL, y=NULL,
       title=sprintf(&quot;U.S. Labor Force Participation Rate %s-Present&quot;, lab_df$lab[1]),
       caption=&quot;Source: EPI analysis of basic monthly Current Population Survey microdata.&quot;) +
  theme_ipsum_rc(grid=&quot;X&quot;)</code></pre>
<p><img alt="" class="wp-image-5076" src="https://i1.wp.com/rud.is/b/wp-content/uploads/2017/02/RStudio-3.png?resize=780%2C256&ssl=1" data-recalc-dims="1"></p>
<h3>Fin</h3>
<p>One takeaway from both these charts is that it’s probably important to take education level into account when talking about the labor force participation rate. The <code>get_labor_force_participation_rate()</code> function — along with most other functions in the <code>epidata</code> package — also has options to factor the data by sex, race and age, so you can pull in all those views to get a more nuanced &amp; informed understanding of this economic health indicator.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://rud.is/b/2017/02/18/putting-it-all-together/"> R – rud.is</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/k79OF3hgv5c"></a></div>