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


##Instructions
Complete this assignment in RStudio. Run all of the chunks, then Knit the markdown file to html. Upload that HTML file to the HW5 assignment on Sakai.

###Load the tidyverse package(s)
```{r}
#install.packages("tidyverse")
library(tidyverse)
```


### Load the data
If you have not already loaded the MLB salary data into R, run the following code chunk. WARNING: If you run this chunk and you already have a dataframe called "MLBPayrolls" then this will overwrite it. That probably won't be a big deal, but I just wanted to make you aware for future cases where it might be a big deal.

```{r}
library(readxl)
download.file("https://mjwebster.github.io/DataJ/spreadsheets/MLBpayrolls.xls", "MLBPayrolls.xls")
MLBpayrolls <- read_excel("MLBpayrolls.xls", 
    sheet = "MLB Payrolls", na = "n/a")
```


### 1. What is the datatype of all the columns?
```{r}
str(    )
```


### 2. Quickly find the minimum, max, median and average salaries for each year.
```{r}
summary(     )
```



### 3. Use the sum() function to calculate the total payroll of all teams in 2004
```{r}
sum(         )
```


### 4. Use the mean() function to calculate the average payroll of teams in 2004
```{r}
mean(        )
```


### 5. Now use the sum() function to calculate the payroll of all teams in 2002. After you get your answer, write a sentence explaining how and why your answer here is different than you answer to the first quesiton. (Hint: try to sum the TEAM column.)
```{r}
sum(    )

```


### 6. How much more (or less) did the Arizona Diamondbacks pay its players in 2016 than it paid in 2002?
```{r}

```

### 7. What ws the percentage increase (or decrease) in the Arizona Diamondback payroll between 2011 and 2016?

```{r}

```

### 8. Use the colSums() function to get the total MLB payrolls for all years.
```{r}


```

### Extra Credit 1: Edit your answer to question #5 to yield a more satisfying answer.
```{r}

```

### Extra Credit 2: You may have noticed in #8 that the formatting was not super easy on the eyes. This is because the colSums() function returns a result in a "named vector" format. It's not actually a dataframe. Here's how you would convert it to a dataframe. For extra credit, use the comments describe what the code is doing on each line. 
```{r}

```
