Some practice problems for maps

Not to be submitted

The Local Area Unemployment Statistics page from the Bureau of Labor Statistics makes available county-level monthly unemployment data for a 14-month window. The file for November 2017 through December 2018 is available at https://stat.uiowa.edu/~luke/data/laus/laucntycur14-2018.txt.

One way to read the data into R is:

lausURL <- "http://www.stat.uiowa.edu/~luke/data/laus/laucntycur14-2018.txt"
lausUS <- read.table(lausURL,
                     col.names = c("LAUSAreaCode", "State", "County",
                                   "Title", "Period",
                                   "LaborForce", "Employed",
                                   "Unemployed", "UnempRate"),
                     quote = '"', sep = "|", skip = 6,
                     stringsAsFactors = FALSE, strip.white = TRUE,
                     fill = TRUE)
footstart <- grep("------", lausUS$LAUSAreaCode)
lausUS <- lausUS[1:(footstart - 1),]

The sub and grep functions may be useful for cleaning the data.

In these problems you will be working with this unemployment data. For each of the following problems

1. State Average Unemployment Rates

Create a choropleth map of the average state unemployment rates over the period covered by the data. In computing the averages keep in mind that the workforce sizes differ across counties.

Hint: The State variable in the lausUS data frame is the state FIPS code. The state.fips data frame in the maps package can be used to map state names to FIPS codes. One possible approach to attaching state FIPS codes to the map data needed for ggplot:

state.fips <-
    select(maps::state.fips, fips, region = polyname) %>%
    mutate(region = sub(":.*", "", region)) %>%
    unique()
gusa <- left_join(gusa, state.fips, "region")

2. Iowa Monthly Unemployment Rates over Time

For the months of March, June, September, and December of 2018 create a choropleth map of the Iowa county unemployment rates for each of these months in a faceted display.

Hint: The County column of the lausUS data frame contains the county portions of the county FIPS codes. The full county FIPS codes can be computed as

with(lausUS, 1000 * State + County)

3. Comparison of Iowa Unemployment Rates

Create a choropleth map of the difference between the Iowa county unemployment rates in Dec 2018 and December 2017.

4. Animated Maps over Time

Create a Shiny app that allows animating through the monthly choropleth maps of county level Iowa unemployment rates. Are there any other interactive features that might be useful? These files are a possible starting point.