```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

For this homework, you will save the `R Markdown` (e.g., `.Rmd`) homework document and save it to your `homework` project directory on your computer. Save a new copy of this file so that its name has the prefix `2023_Lastname_FirstInitial`. Full name example: `2023_cookg_EX_04.Rmd`. 
Feel free to work with a partner but understand that the work submitted has to be your own.

Concepts are starting to build. And all memory research demonstrates the importance of retrieval practice, so you will utilize past and current concepts to answer the homework. This homework utilizes examples from these modules:

- **data frame manipulation and wrangling**
- **data subsets and summaries**
- **ggplot and the grammar of graphics**
- **visualizing amounts**


**This homework is due on Tuesday by 2:30pm.**


*Enter your name in the YAML code*   


```{r}
source(here::here("r", "my_functions.R"))
```

# *Loading libraries*

```{r}
library(magrittr)
library(ggplot2)
library(dplyr)
```


**Questions:**

# *Getting Data*

For this homework, you will use the hammer throw data at: "https://github.com/slicesofdata/dataviz23/raw/main/data/tfrrs/HT.csv"

```{r}


```


# *Getting Unique Events*

(a) Determine the number of unique `Athlete`s in the data set. 

```{r}

```

(b) Determine the number of unique `Meet`s in the data set. 


```{r}

```



# *Creating a bar plot*

(a) Use **{ggplot}** to make a bar plot containing the total count for each `Season`.  

```{r}


```


(b) Use **{ggplot}** to make a bar plot containing the total count of `Year`.  

```{r}


```


# *Comparing geom_col()` vs. geom_bar()*

(a) Use **{ggplot}** to create a bar plot that plots the count for `Athlete`s in the data set. You should end up with a plot that indicates the number of instances that each athlete participated in the data set. Display the names of the Athletes along the y axis so that the names are legible. There are two ways you can do this. I don't care which way you use.

```{r}


```


(b) Another way to create the same plot is to use **{dplyr}** to summarize the number of instances participated in for each athlete and then pass that data frame to **{ggplot}** in order to plot two variables, `Athlete` by `Count`. 

```{r}


```


# *Mutating, Summarizing, and Plotting*

Now, if you want to clean up your `Mark` variable for field events, you will need to convert the vector from character to numeric. However, you will notice a character that will prevent this from being done easily using `as.numeric()`. However, you can use the `gsub()` function to find and replace characters in strings. 

```
gsub(pattern, 
     replacement, 
     x, 
     ignore.case = FALSE, 
     perl = FALSE,
     fixed = FALSE, 
     useBytes = FALSE
     )
```

Looking at this function, `?gsub()`, you will see you will need to pass an argument for the string `pattern` to search for, the string you want that `replacement` to be, and the vector, `x` you want to modify. The other default arguments could be changed if you cannot fix your vector using those defaults. In the end, your goal will be to replace `Mark` with a numeric form (your tibble will display this specifically as type double, a floating-point number). For those curious, `R` tends to convert single-precision values as double-precision values, though this is more memory intensive (64bit). 

`mutate()` is actually a very friendly function. First, you don't have to nest a bunch of functions so that your variable name-value pair is all on one line. If doing so is confusing, `mutate()` will perform the mutation before proceeding to the next name-value pair, so you can break down a mutation into smaller pieces if necessary. 

For example:

```
mutate(., 
  Var1 = "1",
  Var1 = as.numeric(Var1),
  )
```

Second, you will also notice that there is a `,` on the second declaration of `Var1`. Whereas this orphan often breaks functions that are looking for you passing other arguments in that position, this comma does not cause a problem for `mutate()`.

(a) Whether you accomplish the problem in one or two lines, fix the `Mark` variable in the data frame so that you can perform statistical operations on it.

```{r}


```


(b) Then summarize the data so that you compute the `mean()`, `sd()`, and `mad()` `Mark` or each athlete and create a bar plot to visualize the mean distance for each athlete.

```{r}


```

(c) Redo the plot by mapping the bar color to a numeric variable from the summarized data frame.

```{r}


```

**Please knit an `html` file and upload [here](https://claremontmckenna.app.box.com/f/140969a32dea44e9ab6c0c00146d66e3).** 

