blsAPI Updated to Deliver QCEW Data

I have previously posted that I developed a R package to facilitate pulling data from the BLS API.  David Hiles asked that I incorporate pulling in QCEW data that is not available through the standard API.  It was a great idea and so I did it.  It is now posted to CRAN or the GitHub repository.

So if you install/update this R package you will have a blsQCEW() function.  You pass in what type of data you are looking for.  Valid options are: Area, Industry and Size.  Other parameters are needed but depend on what type of request you are making.

Area Data Request

Area request require a year, quarter, and area parameters.  The area codes are defined by the BLS and available here: http://www.bls.gov/cew/doc/titles/area/area_titles.htm.  Here’s a code example for an area request:

# Request QCEW data for the first quarter of 2013 for the state of Michigan
MichiganData <- blsQCEW('Area', year='2013', quarter='1', area='26000')

Industry Data Request

Industry requests require a year, quarter, and industry parameters.  Some industry (NAICS) codes contain hyphens but the open data access uses underscores instead of hyphens. So 31-33 becomes 31_33. For all industry codes and titles see: http://www.bls.gov/cew/doc/titles/industry/industry_titles.htm.  Here’s a code example for pulling making a construction industry request:

# Request Construction data for the first quarter of 2013
Construction <- blsQCEW('Industry', year='2013', quarter='1', industry='1012')

Size Data Request

Data by size is only available for the first quarter of each year. To make this type of request, you only need to provide the size and the year parameters. The size codes are available here: http://www.bls.gov/cew/doc/titles/size/size_titles.htm.  Here’s a code example:

# Request data for the first quarter of 2013 for establishments with 100 to 249 employees
SizeData <- blsQCEW('Size', year='2013', size='6')

I also want to mention that the blsAPI() function has been changed to return data either as a JSON string or as a data frame. I hope others will find these improvements helpful.

Status

BLS Featuring My R API Wrapper

I was in the process of cleaning up my package for submission to CRAN when I learned that the BLS has released v2 of their API service.  This version requires a key but allows for more requests plus annual average calculations which is cool.

I was shocked and gratified to see that under the Sample Code: R page they were featuring my work with this acknowledgement:

bls_api

My submission to CRAN has not accepted yet, but I’m still working on it.  In the mean time it is available through GitHub.

Aside

There Is No Such Thing As The U.S. Economy

While working at the Bureau of Labor Statistics in New York City, I recall overhearing a colleague comment that there is no such thing as the U.S. economy.  Instead, he said, there are a lot of little economies.  That really stuck with me and in this vein I am proud to share what I’ve been up to lately.

I have been thinking about the employment situation in the United States, especially after the Great Recession.  I wanted to get a feel for how many jobs have returned keeping in mind that each metro could have a different story.

gr-employment-indexI use R to create metro level indexes of employment and then visualized them.  I found the visualization so intriguing that I created a Shiny app.  The app allows you to produce what I lovingly refer to as moustache graph as seen to the left.  You can view the difference between the Midland, TX and the Dalton, GA’s post Great Recession employment stories.  When viewing the visualization, I am inclined to think that my colleague at the BLS was right.  There is no such thing as the U.S. economy.

Note: You can access the app at https://mikesilva.shinyapps.io/metro-employment-index/ and read how the index was derived at http://rpubs.com/mikesilva/metro-employment-index.