---
title: "PA 10: Map it!"
subtitle: "Plotting Geographic Data"
format: 
  html:
    code-tools: true
    toc: true
    number-sections: true
editor: source
execute: 
  error: true
  echo: true
  message: false
  warning: false
---

```{r setup}
#| include: false
library(tidyverse)
library(maps)
library(mapproj)
```

Make sure you are also working with the online version of this assignment for tips!

## Data

`secret_map.csv` contains a secret code for each county in the U.S. In this PA, you will figure out the code and then create a map in `ggplot` showing what you found.

```{r}
# read in and save secret_map.csv
```

## Simple Map of US Counties

Let's start by just creating a map of all of the counties in the continuous US. 

1. Use the `map_data()` function to load a dataframe of US **counties** with their latitudes and longitudes. Save this data as `county_map`.

```{r}
# code for Q1
```


2. Using `ggplot()`, generate a map of the US counties. Have the fill color for each county be white and the outline color be a dark grey. Use cartesian coordinates.


```{r}
# code for Q2-3
```

3. If you haven't already, remove any axis labels and normal plot grid lines. You can remove the default grey ggplot background as well if you prefer!

4. While cartesian coordinates are typical, they are actually somewhat visually misleading since the globe is a sphere. A recommended system for showing the US is the "Albers Equal Area Conic Projection". Copy and paste your code from Q2-3 and change the coordinate system to this projection (or any conic projection). 


```{r}
# code for Q4
```

Great! Now you should have a nice simple map of all of the US counties. Let's add the information from the `secret_map.csv` data.

## Color that Map

5. First of all, word is just in that there are a couple of typos in the `secret_code` column:
  a. Any "g" should be replaced with "F" (case matters!)
  b. The secret code should start with the hashtag character (#)
  
```{r}
# code for Q5
```

6. It turns out that the secret code gives you the colors that should be used in your final map. Save a **vector** called `map_colors` with the **unique** values of the `secret_code` column (after the cleaning in Q5).

```{r}
# code for Q6
```


7. Now map it! Fill the counties as indicated in the secret map data with the appropriate color (as given by `secret_code`) in your US map. 

```{r}
# code for Q7-8
```


8. Finally, also change the outline color for counties to the appropriate color for the county based on the `secret_code`. Submit a screenshot of this final plot in your Canvas submission!

## Canvas Submission: 

> Submit a screenshot of your final plot. What flag is shown?
