---
title: "Module 1, Assignment 2: Getting to Know the Team"
author: "Ellen Bledsoe"     # <- your name here!
date: "`r Sys.Date()`"      # <- uses the current date when rendered
output: pdf_document
---

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

# Assignment Description

### Purpose

The goal of this assignment is to get comfortable using R to look at 1- and 2-dimensional data sets.

### Task

Write R code to successfully answer each question below.

### Criteria for Success

-   Code is within the provided code chunks
-   Code chunks run without errors
-   Code produces the correct result
    -   Code that produces the correct answer will receive full credit
    -   Code attempts with logical direction will receive partial credit
-   Written answers address the questions in sufficient detail

### Due Date

February 7 at midnight MST

# Assignment Questions

*Remember to run each chunk of code as you go!*

Each question is worth 2 points.

## Vectors

Let's start working with vectors, or 1-dimensional data, first.

**IMPORTANT!**\
Run this chunk of code to create a vector of data to use.

```{r vector}
# Vector with counts of penguins
counts <- c(2, 9, 4, 3, 6, 7, 1, 0, 3)
```

1.  What data class is `counts`? Write a line of code that tells you.

```{r data_class}

```

2.  Write a line of code that pulls out the 2nd value in the `counts` vector.

```{r second_value}

```

3.  Calculate the average number of penguins that were counted.

```{r avg_penguins}

```

## Data Frames

Now that we've practiced with vectors, let's move on to 2-dimensional data.

Remember that quiz we took in class with fun/silly questions about our trip to Antarctica? It's time to play around with that data!

**IMPORTANT!**\
The following code chunk will read in the data. Be sure to run it before try to answer the questions! A bunch of stuff will pop up, but it should work just fine.

```{r import_data}
# load library
library(tidyverse)

# Load data
team_data <- read_csv("../data/team_antarctica_responses.csv") %>% drop_na()
```

Running the code chunk above produces a message that gives us some useful information, even before we look at the data set (alternatively, you can check it out in the environment tab to the right).

-   What are the dimensions of the data?
-   What are the names of the columns in the data?
-   What data *class* do you expect to find in each column (i.e., numbers, character strings, T/F, etc.)

4.  Take a look at the data frame using the `head()` function. Typically, `head()` provides the first 6 rows of data. Modify one of the arguments in `head()` so that the line of code prints the first 10 rows. (If you aren't sure how to do that, remember how you can look for help about functions!)

```{r examine_data}

```

5.  Using what you know about sub-setting data frames, write a line of code the pulls out the parka color for uniqueID 9 (row 9). (Hint: count the columns!)

```{r parka7}

```

When we have a large data set like this, it is often helpful to summarize the data in some way. The next few questions will help use get a better understanding of the content of the data set.

6.  On average, how did people rate their ability to be in a remote location?

```{r average_cold_tolerance}

```

7.  What are the minimum and maximum distances that would be traveled by a team member to get to Antarctica? Use the `min()` and `max()` functions.

```{r min_max_distance}
# Minimum distance


# Maximum distance

```

8.  Create a data frame that only includes rows of data for people who rated their fishing skills as a 5. (Hint: numbers do not need quotation marks around them).

```{r cooking_skill}

```

9.  Write a line of code that tells us what data class the `good_with_animals` column is.

```{r good_with_animals}

```

10. Calculate the average cold tolerance of people who want blue parkas. Use these steps to think through how to answer this question.

    a.  First, think about how to create a data frame with only people who want blue parkas

    b.  Next, think about how you select the column with the cold tolerance data

    c.  Finally, think about how to calculate the average

```{r parka_colors}

```

## Bonus (up to 2 points)!

What animal should be on our team flag?

First, create a vector called `mascot` that has only the values from the `flag_mascot` column. Next, use the `table()` function on the `mascot`. This will give you the number of times each option was chosen. According to the results, which animal should be on our team flag?

```{r flag_mascot}

```

***Answer:***

# Turning in Your Assignment

Follow these steps to successfully turn in your assignment on D2L.

1.  Click the `Knit` button up near the top of this document. This should produce a PDF file that shows up in the `Files` panel on the bottom-right of your screen.
2.  Click the empty box to the left of the PDF file.
3.  Click on the blue gear near the top of the `Files` panel and choose Export.
4.  Put your last name at the front of the file name when prompted, then click the Download button. The PDF file of your assignment is now in your "Downloads" folder on your device.
5.  Head over to D2L and navigate to Module 1 Assignment 2. Submit the PDF file that you just downloaded.
