---
title: "Midterm 1 Template"
author: "Insert Name"
date: "Math 141, Spring 2021"
output:
  pdf_document
urlcolor: blue
---

```{r setup, include=FALSE}
# Do not modify this chunk.
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(knitr)
library(moderndive)
```





## Instructions

1. Download the Midterm 1 .Rmd Template (this file).

2. Work through the exam questions in the .pdf file on [Gradescope](https://www.gradescope.com/courses/227442), recording your answers in the .Rmd template, and submit the document as a knitted .pdf file with your answers on Gradescope. Only what appears in the .pdf file will be graded, so if what you see in the .pdf doesn't reflect what you intend for the answer, modify your .rmd file so the .pdf reflects your answer.

3. You may take up to 120  minutes to complete this exam. You may start the exam at any time, but you must cease working and submit your .pdf file 120 minutes after you begin. You will be unable to submit the assignment to gradescope after this time has elapsed. If you have academic accommodations permitting additional time on the exam, and we have discussed these accommodations, I have incorporated the additional time in your assignment.

4. You may reference your Lab Assignments (both the versions you submitted and the comments you received), your course notes, textbooks (both ModernDive and OpenIntro), lecture slides, and lecture videos. 

5. You may also reference any built-in help functions in R (for example, you may look at the results of typing `?ggplot` into the console or the cheat sheets on the help menu). 

6. You **MAY NOT** reference any other physical or online sources, repost any questions from this exam, or receive help on this assignment from others in any way. Failure to abide by this policy is an Honor Code violation.

7. If you have technical questions, send them to Nate and Tom as a joint direct message on Slack. For equity reasons, we will not answer conceptual or clarifying questions. Since we maybe unable to answer your question during the time frame you are taking the exam, document the issue on the exam and then move on to the next problem.

8. Knit your document early and often! If a code chunk is preventing you from knitting the document and you are unable to resolve the problem, replace `{r}` at the top of the code chunk with `{r eval = F, echo = T}`. The code will not run, but will be printed in your .pdf which can possibly earn some partial credit.

9. For each problem, put your solution between the bars of red stars.


## Data

This exam will make use of the `pdxTrees` data set, an inventory of trees in Portland, OR gathered by volunteers and city employees between 2017 and 2019. More information on the data can be found [here](https://www.portlandoregon.gov/parks/article/501565).

The data is available as part of the `pdxTrees` package. After the package is loaded, the data can be obtained using the function `get_pdxTrees_parks()`, which will automatically import the data from the web. Run the following code to load the package and import the data as `trees`.

```{r}
library(pdxTrees)
trees <- get_pdxTrees_parks()
```

The `trees` data contains information on 34 variable for 25534 trees in Portland parks. Run the following code to view the help file for the data set. The **Value** section of the help file describes each variable in the data set. *Note that `eval = F` is used so the help file does not produce an error when knitting the document.*

```{r eval = F}
?get_pdxTrees_parks()
```

During the exam, we will focus on only a subset of the variables in the data. Run the following code to reduce the data to  `Common_Name`, `DBH`, `Condition`, `Tree_Height`, `Crown_Base_Height`, `Park`, `Functional_Type`, `Carbon_Storage_lb`, and `Pollution_Removal_oz`.

```{r}
trees <- trees %>% select(Common_Name, 
                          DBH, 
                          Condition, 
                          Tree_Height, 
                          Crown_Base_Height, 
                          Park, 
                          Functional_Type,
                          Carbon_Storage_lb, 
                          Pollution_Removal_oz)
```


Since this data set is very large, we will restrict our attention to just 4 parks: `Sellwood Park`, `Westmoreland Park`, `Woodstock Park`, and `Powell Park`. Run the following code to reduce the data.

```{r}
trees <- trees %>% filter(Park %in% c(
  "Sellwood Park",
  "Westmoreland Park",
  "Woodstock Park",
  "Powell Park")
)
```


Perform some preliminary data exploration to understand the distribution of each variable, along with the relationships among the variables. 

To facilitate exploration, you may want to make a copy of this .Rmd file called `Midterm1_Scratchwork` where you can make changes to the data without impacting the version of this template you will use to submit your exam.






## Exam

Write your answers to questions in the Midterm 1 .pdf between the bars of red stars below. You may copy and paste the questions from the .pdf file into the space below (but you do not need to).


### Problem 1




*************************************************************





*************************************************************





### Problem 2




*************************************************************





*************************************************************







### Problem 3




*************************************************************





*************************************************************








### Problem 4




*************************************************************





*************************************************************







### Problem 5




*************************************************************





*************************************************************






### Problem 6




*************************************************************





*************************************************************