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:
You must submit your
.Rmd file on time. It must be named exactly as specified, and it must knit without errors to produce a
.html file should read as a well written report, with all results and graphs supported by text explaining what they are and, when appropriate, what conclusions can be drawn. Your report should not contain any extraneous material, such as leftovers from a template.
The R code in your
.Rmd file must be clear, readable, and follow the coding standards.
The text in your
.Rmd file must be readable and use R markdown properly, as shown in the class template file.
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
In this file present your answers to the following problems. Your presentation should follow the pattern and guidelines in the class template file.
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?
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 2021 through February 2022 is available is available at http://www.stat.uiowa.edu/~luke/data/laus/laucntycur14-2021.txt.
One way to read the data into R is:
lausURL <- "http://www.stat.uiowa.edu/~luke/data/laus/laucntycur14-2021.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),]
grep functions may be useful for cleaning the data.
Compute the average unemployment rate for each of the 99 Iowa counties over this period and identify the county with the highest and the county with the lowest average unemployment rate over this period.
For the counties with the highest and lowest average unemployment rates plot their monthly unemployment rates over time in a single plot.
You can create an HTML file in RStudio using the
Knit tab on the editor window. You can also use the R command
with your working directory set to
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