Labor Market Analysis with R: Will Obama Ever be Beat?

February 13, 2017

(This article was first published on R Tricks – Data Science Riot!, and kindly contributed to R-bloggers)

No matter how many jobs are promised, Barak Obama’s administration will be nearly impossible to beat when it comes to employment growth. The following code uses the blcrapeR package, which is available on CRAN.

Politicians talk a lot about jobs and unemployment, even though the actual power they have over the labor market is up for debate. Before you comment, please know I have no interest in politics, but ggplot2 is my friend!


df <- bls_api(c("LNS12000000", "LNS13000000", "LNS14000000"),
              startyear = 2008, endyear = 2017) %>%
    # Add time-series dates
# Plot employment level
gg1200 <- subset(df, seriesID=="LNS12000000")
ggplot(gg1200, aes(x=date, y=value)) +
    geom_line() +
    labs(title = "Employment Level - Civ. Labor Force")

# Plot unemployment level
gg1300 <- subset(df, seriesID=="LNS13000000")
ggplot(gg1300, aes(x=date, y=value)) +
    geom_line() +
    labs(title = "Unemployment Level - Civ. Labor Force")

gg1400 <- subset(df, seriesID=="LNS14000000")
ggplot(gg1400, aes(x=date, y=value)) +
    geom_line() +
    labs(title = "Unemployment Rate - Civ. Labor Force")

To leave a comment for the author, please follow the link and comment on their blog: R Tricks – Data Science Riot!. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)