---
title: "Lab 13.1 - Gerrymandering in Michigan?"
author: "Author Goes Here"
date: "Semester Goes Here"
output:
  pdf_document:
    latex_engine: xelatex
---

The goal of this exercise is assess whether gerrymandering is an issue in Michigan.

## Exploratory Data Analysis Assignment

```{r echo=FALSE, message=FALSE}
library(tidyverse)
library(mdsr)
```

🚧
Work through the text's analysis of gerrymandering in North Carolina (Section 17.4), but use data for Michigan instead. Go through the same steps, giving abbreviated but complete explanations on all data and visualizations. Finally, give your conclusion on whether Michigan also has gerrymandering, supporting your conclusion with accurate data and compelling visualizations.

We make the use of Leaflet, as they use it in their example, optional for this lab. If you use Leaflet, you&rsquo;ll need to render your document using HTML, because Leaflet is an HTML-based tool that creates interactive Web maps. Do this by replacing this part of the YAML header:

```{r eval=FALSE}
output:
  pdf_document:
    latex_engine: xelatex
```

with this:

```{r eval=FALSE}
output: html_document
```

## Data Wrangling Notes

GIS data tends to be voluminous. In this lab, you'll discover that the district shapes data files used in the text consume around 80 MB (plus the original zip file). Note that you need to download these files to do your work, either to your local or your cloud RStudio environment, but that you do not want to include them in your lab assignment submission.

The text includes code to download and unzip the district shape files needed for this assignment, but that code doesn't reliably work (for us, anyway), so, as a work-around, we suggest that you manually download and unzip the specified file: `http://cdmaps.polisci.ucla.edu/shp/districts113.zip`. Be sure that the district shapes sub-directory is stored directly in your data sub-directory, i.e., in `data/districtShapes`. To save disk space, you can delete the zip file after it has be unzipped.

When the data is fully downloaded and unzipped, you can use this code chunk to load and access `dsn_districts` directly from your local copy.

``` {r eval=FALSE}
library(sf)

dsn_districts <- fs::path(fs::path_wd(), "data", "districts113", "districtShapes")
st_layers(dsn_districts)
```
Make sure that the sub-directory path specified in `fs::path` matches the path to the `districtShapes` sub-directory on your system.
