This post grabs the latest unemployment number for each state from FRED and makes a map using statebin. This map uses 5 break points and is a quick and dirty way to visually view the unemployment conditions in the US. Map US unemployment Using statebin and r

# this grabs the end of the file which should have the latest month
library(statebins)
library(lubridate)

base = "http://research.stlouisfed.org/fred2/data/"
end = "UR.txt"
len <- read.table(paste0(base, "WA", end), skip= 12, header=F, as.is=T, col.names=c("date", "value"))
get_rows = nrow(len)+11 ###### add 11 to account for the header file rows
state = state.abb


# put loop for all 50 states and create master list of all downloads
ui <- lapply(state, function(.st) {
  state = paste0(.st)
  input <- read.table(paste0(base, .st, end), skip= get_rows, header=FALSE, as.is=TRUE, col.names=c("date", "value"))
  input$state = state

  input
})
ui_cur <- do.call(rbind, ui)


# get the month and year using lubridate and add title here, this should grab latest month from FRED
month = as.vector(unique(month(as.Date(ui_cur$date), label = TRUE, abbr = TRUE)))
year = unique(year(as.Date(ui_cur$date)))
title = paste0("Average Unemploymnet by State ", month, "-", year )

# Use the statebin library here to create a map with 5 break points
statebins(ui_cur, breaks=5,
          labels=c("2-5%", "5-6%", "6-7%", "7-8%", "8-14%"),
          brewer_pal="PuRd",
          text_color="black",
          font_size=4,
          legend_title= title,
          legend_position="top")