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.
The .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 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.
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?
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 2023 through February 2024 is available is available as an Excel file at https://stat.uiowa.edu/~luke/data/laus/laucntycur14-2024.xlsx.
One way to read the data into R is:
laus14file <- "laucntycur14-2024.xlsx"
if (! file.exists(laus14file)) {
laus14URL <- paste0("http://www.stat.uiowa.edu/~luke/data/laus/",
laus14file)
download.file(laus14URL, laus14file, mode = "wb")
}
lausUS <- readxl::read_xlsx(laus14file, skip = 5)
footstart <- which(is.na(lausUS[1]))
lausUS <- lausUS[1:(footstart - 1),]
names(lausUS) <- c("LAUSAreaCode", "State", "County",
"Title", "Period",
"LaborForce", "Employed",
"Unemployed", "UnempRate")
lausUS$Period <- substr(lausUS$Period, 1, 6)
If you are having trouble reading the downloaded .xlsx file you can try downloading a zip version of the file with
zipURL <- "http://www.stat.uiowa.edu/~luke/data/laus/laucntycur14-2024.zip"
zipfile <- "laucntycur14-2024.zip"
download.file(zipURL, zipfile)
unzip(zipfile)
You will need to rename the extracted .xlsx file or adjust the rest of the code.
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
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