<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/highcharting-jobs-friday/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rviews.rstudio.com/2018/08/09/highcharting-jobs-friday/"> R Views</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p> <br>
<br>


<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>



</p>
<p>Today, in honor of last week’s jobs report from the <a rel="nofollow" href="https://www.bls.gov/" target="_blank">Bureau of Labor Statistics</a> (BLS), we will visualize jobs data with <code>ggplot2</code> and then, more extensively with <code>highcharter</code>. Our aim is to explore <code>highcharter</code> and its similarity with <code>ggplot</code> and to create some nice interactive visualizations. In the process, we will cover how to import BLS data from FRED and then wrangle it for visualization. We won’t do any modeling or statistical analysis today, though it wouldn’t be hard to extend this script into a forecasting exercise. One nice thing about today’s code flow is that it can be refreshed and updated on each BLS release date.</p>
<p>Let’s get to it!</p>
<p>We will source our data from <a rel="nofollow" href="https://fred.stlouisfed.org/" target="_blank">FRED</a> and will use the <code>tq_get()</code> function from <code>tidyquant</code> which enables us to import many data series at once in tidy, <code>tibble</code> format. We want to get total employment numbers, ADP estimates, and the sector-by-sector numbers that make up total employment. Let’s start by creating a <code>tibble</code> to hold the FRED codes and more intuitive names for each data series.</p>
<pre><code>library(tidyverse)
library(tidyquant)

codes_names_tbl &lt;- tribble(
        ~ symbol, ~ better_names,
        &quot;NPPTTL&quot;, &quot;ADP Estimate&quot;,
        &quot;PAYEMS&quot;, &quot;Nonfarm Employment&quot;,
        &quot;USCONS&quot;, &quot;Construction&quot;,
        &quot;USTRADE&quot;,   &quot;Retail/Trade&quot;,
        &quot;USPBS&quot;,  &quot;Prof/Bus Serv&quot;,
        &quot;MANEMP&quot;,    &quot;Manufact&quot;,
        &quot;USFIRE&quot;,    &quot;Financial&quot;,
        &quot;USMINE&quot;,   &quot;Mining&quot;,
        &quot;USEHS&quot;,    &quot;Health Care&quot;,
        &quot;USWTRADE&quot;,    &quot;Wholesale Trade&quot;,
        &quot;USTPU&quot;,    &quot;Transportation&quot;,
        &quot;USINFO&quot;,    &quot;Info Sys&quot;,
        &quot;USLAH&quot;,    &quot;Leisure&quot;,
        &quot;USGOVT&quot;,    &quot;Gov&quot;,
        &quot;USSERV&quot;,    &quot;Other Services&quot;
)</code></pre>
<p>Now we pass the <code>symbol</code> column to <code>tq_get()</code>.</p>
<pre><code>fred_empl_data &lt;- 
  tq_get(codes_names_tbl$symbol,                         
         get = &quot;economic.data&quot;,             
         from = &quot;2007-01-01&quot;)</code></pre>
<p>We have our data but look at the <code>symbol</code> column.</p>
<pre><code>fred_empl_data %>% 
  group_by(symbol) %>% 
  slice(1)</code></pre>
<pre><code># A tibble: 15 x 3
# Groups:   symbol [15]
   symbol   date         price
   </code></pre>