Guidelines

You will submit your homework as an R Markdown (.Rmd) file by committing to your git repository and pushing to GitLab. We will knit this file to produce the .html output file (you do not need to submit the .html, but you should make sure that it can be produced successfully).

We will review both your .Rmd file and the .html file. To receive full credit:

Create a new folder called HW9 in your repository. Use exactly this spelling with upper case letters. You can do this in the RStudio IDE, with R’s dir.create function, or using a shell.

In this folder, create a new Rmarkdown file called hw9.Rmd. Again use exactly this spelling. RStudio will give you a template, or you can use the one available here. Commit your new file to your repository. (If you are using git in a shell you will need to use git add before git commit).

In this file present your answers to the following problems. Your presentation should follow the pattern and guidelines in the class template file.

1. Economic Data

The economics data set in the ggplot2 package contains five US economic indicators recorded over about 40 years. Plot the time series, standardized in an appropriate way, in a single plot and in five separate panels with their own vertical scales. Describe any interesting features you can see in the data. Are there features that are easier to see in a single plot or in the separate plots?

2. Unemployment Rates

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 January 2022 through February 2023 is available is available at https://stat.uiowa.edu/~luke/data/laus/laucntycur14-2022.txt.

One way to read the data into R is:

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

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

Create an HTML File and Commit Your Work

You can create an HTML file in RStudio using the Knit tab on the editor window. You can also use the R command

rmarkdown::render("hw9.Rmd")

with your working directory set to HW9.

Commit your changes to your hw9.Rmd file to your local git repository. You do not heed to commit your HTML file.

Submit your work by pushing your local repository changes to your remote repository on the UI GitLab site. After doing this, it is a good idea to check your repository on the UI GitLab site to make sure everything has been submitted successfully