---
title: "Lab Assignment 6"
subtitle: "Review"
author: [Your name here]
date: today
format:
  html:
    theme: cosmo
    toc: true
    toc-location: left
    toc-depth: 2
    highlight-style: github
    code-copy: true
    embed-resources: true
    df-print: paged
    fig-align: center
    fig-width: 8
    fig-height: 6
execute:
  message: false
editor: visual
---

*Note: The header at the top of this file has a bunch of settings to make your rendered html look nice. Don't worry about it (just add your name)!*

## Instructions

Wow.....the end of an era. Your 6th and final lab assignment has arrived. What a momentous occasion.

This assignment is your most open-ended and most difficult one yet. For this assignment, you're going to practice conducting a full data analysis, from start to finish.

For your lab assignments, you may use AI to help you code. You will be required to explicitly fill out the **SPARCK** framework for each question. **You may not use AI to write the non-coding parts of the framework,** although you may consult it for assistance.

You should guide me through the answer the questions. This means you shouldn't just copy and paste code from AI and be done with it; you should intersperse code and plain text throughout so that you can clearly explain what your code is doing.

Remember that you must render your Quarto document into an html file. This html is what you should hand in on Canvas. If you encounter errors, use AI to help you troubleshoot!

**Make sure you put this Quarto file in your Week 8 folder, and then open the file from that folder so that R's working directory is your Week 8 folder.**

**S: Set up** (What is your end goal?)

**P: Pseudocode** (What are the steps?)

**A: AI** (What are your AI prompts?)

**R: Run** (Run it!)

**C: Check** (Did your code work?)

**K: Knowledge** (What does your code mean?)

Remember, for K, I want you to translate your code into plain language. Do not use K to report the output of your code.

### Graph-specific instructions

For all graphs you make, they should look good. This means they have clear labels (including a title and axis titles that a normal human can understand), pretty colors, and bars in a sensible order. Essentially, if you were giving a talk on this topic, your graph should look like it belongs in your presentation.

## Question 1: Getting the data

You have a lot of choice in what data you use for this assignment. The only requirement is that you use one of the "American Trends Panel Wave" datasets from the Pew Research Center.

To access these datasets, go to <https://www.pewresearch.org/> and create an account. Then go to Tools & Datasets, then Dataset Downloads. You'll then see a list of publicly available datasets. **I only want you to use one of the American Trends Panel Wave datasets.**

For each ATPW dataset, you can click on it to see associated Pew Research Center articles. This will help you determine which dataset you're interested in working with. Feel free to look as far back in the Pew database as you'd like. (I hope you'll explore beyond the first page of listed datasets!)

Once you've picked a dataset, you can download it by clicking the "Download Dataset" button. This will download a whole bunch of files to your computer. The most important ones are the csv file, which contains your data and which you should put in the same R Project folder as this tutorial, and the Codebook file, which explains what the variable names and responses in the data file mean.

**Question: Which ATPW dataset did you download (provide the number), and what about it interested you?**

**Your answer:**

Below, load `tidyverse` and whatever other packages you end up using (it's always a good idea to load all packages at the start of your script, and you only need to do so once), and then read in the data.

```{r}

```

## Question 2: A t-test

Questions 2 and 3 in this lab assignment will be their own data analyses. For this question, you'll need to do the following:

- **Clean the data.** Get it in the correct format you need for your planned analysis. It's possible this involves simply creating a new dataframe where you've selected just the relevant variables, but you may want to transform your data in some way or combine multiple columns together to create a new variable.

- **Descriptive statistics.** Describe the shape of the data using descriptive statistics, and visualize the data in some way.

- **Inferential statistics.** Analyze the relationship between two or more variables *using a t-test*. Then, visualize the relationship you've analyzed.

Remember that SPARCK is designed to assist your learning alongside using AI. S is where you tell me the question you want to answer, and P is where you show me the coding steps you need to take to get there.

For R, you should intersperse multiple code chunks with explanations of what you're doing. At the end of R, you should clearly explain your analysis in plain language and describe the theoretical and/or policy implications of that finding. This is good practice for the Results section of your final paper!

**S:**

**P:**

**A:**

**R:**

```{r}

```

(You may insert as many code chunks as you'd like. You can do so by going to Insert \> Executable Cell \> R in the toolbar above. Remember to conclude with an explanation of your finding in plain language and what it implies.)

**C:**

**K:**

## Question 3: A linear regression

Same thing as above, but this time, your analysis should be based on a linear regression.

**S:**

**P:**

**A:**

**R:**

```{r}

```

(You may insert as many code chunks as you'd like. You can do so by going to Insert \> Executable Cell \> R in the toolbar above. Remember to conclude with an explanation of your finding in plain language and what it implies.)

**C:**

**K:**
