
---
title: "M5: A closer look at your data"
author: "Your group's names (and SUNet IDs)"
date: "`r Sys.Date()`"
output: pdf_document
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
library(coursekata)
library(here)
```

<!-- Fill in every line marked [...]. The step numbers match the steps on the
handout. One of you should knit this to PDF (Session -> Restart R, then
Knit -> Knit to PDF) and submit this file and the PDF on Gradescope, adding
the other members of your group. -->

## Step 1. Your folder

- **Who will upload the changed files to the shared folder at the end of class:** [...]

## Step 2. Your two questions

- **Question 1:** [...]
- **Question 2:** [...]
- **Changes you made after your TA's suggestions in M4:** [...]

## Step 3. The data dictionary

<!-- Fill in data/data-dictionary.md (in your project folder), one row for
every variable in your two questions. Then list them here. -->

- **The variables in your dictionary:** [...]
- **Where you found how each was measured (a link or the name of the document):** [...]

## Step 4. Each variable on its own

```{r raw-data}
# Replace this with the code that reads your raw file, for example:
#   raw <- read.csv(here("data", "raw", "your-file.csv"))
# (Fingers is only here so the file knits before you start.)
raw <- Fingers
```

<!-- One plot per variable in your questions: gf_histogram() for a
quantitative variable, gf_bar() for a categorical one. Add chunks and lines
as you need them. -->

```{r one-variable-plots}
# Replace these with your variables.
gf_histogram(~ Thumb, data = raw)
gf_bar(~ Sex, data = raw)
```

- **Variable:** [...] **Where most values are, and anything odd:** [...]
- **Variable:** [...] **Where most values are, and anything odd:** [...]

## Step 5. Preparing the data

<!-- Start from your M4 plan: the two questions and the variables you said
you'd need. Then edit R/prepare-data.R: keep and rename columns, turn
missing-value codes into NA, recode values, reshape if one row isn't one
case, and drop cases if you need to (only for a reason you can state). You
can use an AI tool to help write the code if you want: give it your plan,
paste the str() output, and describe each change in plain words. Then check
with str() or tally() that the code did what you asked. -->

- **What your M4 plan says you need (the variables, the groups you'll compare, and the form each variable needs to be in):** [...]
- **Each change, and why you made it (with reference to your plan):** [...]
- **Any cases you dropped, why, and how many rows each rule removed (or "none"):** [...]
- **A variable one of your questions needs that is not in your dataset (or "none"): what it would measure, its units or levels, and how it would be measured:** [...]

## Step 6. Saving the processed data

<!-- Run R/prepare-data.R here. It reads data/raw/, recodes the data (and drops any cases you decided to drop),
runs R/checks.R, and saves the result to data/processed/. When it works,
take the # off the two lines below and delete the "processed <- raw" line.
From here on, everything reads the processed file. -->

```{r prepare-data}
# source(here("R", "prepare-data.R"))
# processed <- read.csv(here("data", "processed", "processed-data.csv"))
processed <- raw

nrow(raw)
nrow(processed)
```

## Step 7. Your checks

<!-- Your checks are in R/checks.R, which prepare-data.R runs. Copy them here
so they appear in the PDF. -->

- **Check 1:** [...]
- **Check 2:** [...]
- **Check 3:** [...]
- **Did any check fail at first? If so, was your belief or your code wrong?** [...]

## Step 8. Summary statistics

```{r summaries}
# Replace these with your variables. For question 1, if the explanatory
# variable is categorical, add a summary by group: favstats(outcome ~ group, data = processed)
favstats(~ Thumb, data = processed)
favstats(Thumb ~ Sex, data = processed)
tally(~ Sex, data = processed)
```

**What the numbers tell you:** [...]

## Step 9. A plot for question 1

```{r question-1-plot}
# Replace this with your plot: outcome on the y-axis.
gf_point(Thumb ~ Height, data = processed)
```

- **Which way the relationship goes:** [...]
- **Roughly how strong it looks:** [...]
- **How much the values overlap or spread around it:** [...]

## Step 10. What you've found so far for question 2

```{r question-2-plot}
# If the other variable is in your data: replace this with a plot (color, or a
# panel for each group with gf_facet_grid()) or a table that brings it in.
# If it isn't, delete this chunk.
gf_point(Thumb ~ Height, data = processed, color = ~ Sex)
```

**Does the relationship from question 1 look the same once you bring in this variable, or does it change? (If the variable is not in your dataset: the pattern you would expect to see if you had the variable you described in step 5.)** [...]

## Step 11. What you've learned so far

- **What your plots and numbers suggest about question 1:** [...]
- **What they suggest about question 2:** [...]
- **What you'd want to test in M6:** [...]
