---
title: "Report Template (Replace this title: maximum 80 characters)"
subtitle: "431 Project A"
author: "Your Name (or Names) Should Be Here"
date-modified: last-modified
format: 
  html:
    toc: true
    number-sections: true
    code-fold: show
    code-tools: true
    code-overflow: wrap
    embed-resources: true
    date-format: iso
    theme: pulse  ## change the theme if you prefer
---

# R Packages

```{r}
#| message: false

knitr::opts_chunk$set(comment = NA) # do not remove this

library(janitor) 
library(naniar)
library(infer)
library(xfun)
library(patchwork)

# load other packages as desired here

library(easystats)
library(tidyverse) # load tidyverse last

theme_set(theme_bw()) # or use theme_lucid() if you prefer
```

# Data Ingest

Replace these instructions with your Data Management Task A work. At the end of this section, you should have two tibbles, named **projA_1** and **projA_2**.

# Selecting States

Replace these instructions with your Data Management Task B work.

```{r}
set.seed(431) #  you need to replace this seed with a number of your own
sample(c("AR", "CO", "MI", "NE", "OR", "PA", "TN", "WA"), 
       size = 2, replace = FALSE)
```

Be sure to replace these instructions with the details of how you filtered the **projA_2** tibble you created to include only the two states your random seed selected.

# Create the Master Tibble

Replace these instructions with your Data Management Task C AND Task D work. You'll need to address four variables in your **projA_2** tibble, then merge together the information in your **projA_1** and **projA_2** tibbles to create **projA_master**.

# Manage Names and Types

Replace these instructions with your Data Management Task E AND Task F work. At the end of this section, your **projA_master** tibble should have no more names of the form `vXXX` and you should include a `str()` or `glimpse()` result here after fixing any problematic variable types to demonstrate that your variables are now of the appropriate types.

# Create a New Factor

Replace these instructions with your Data Management Task G work.

# Printing the Tibble

```{r}
#| eval: false ## you will need to remove this eval: false line entirely
projA_master
```

Replace these instructions with a paragraph verifying that your printed tibble (obtained using the code above) meets the specifications laid out in Data Management Task H.

# The Codebook

```{r}
#| eval: false ## you will need to remove this eval: false line entirely
data_codebook(projA_master, max_values = 7, range_at = 15)
```

Replace these instructions with a paragraph verifying that your tibble passes all of the element checks specified in Data Management Task I.

# Saving the Tibble

Replace these instructions with R code to save the master tibble appropriately as an R data set. Use the `write_rds()` function to do this. Be sure to include your name as part of the name of the R data set.

# Comparison 1

## Research Question 1

Replace these instructions with your introductory paragraph for this comparison, including your research question. As part of the paragraph, specify the number of counties which have complete data on life expectancy, and specify the details on how this measure was obtained by the County Health Rankings, and what year it describes.

## Visualization 1

Replace these instructions with your visualization for this comparison.

## Table 1

Replace these instructions with your table for this comparison.

## Results 1

Replace these instructions with a paragraph that adequately describes the key findings shown in your visualization and table, in light of your research question.

# Comparison 2

## Research Question 2

Replace these instructions with your introductory paragraph for this comparison, including your research question. As part of the paragraph, specify the number of counties which have complete data on the two measures of interest in this comparison.

## Scatterplot A

Replace these instructions with your first scatterplot, where the y and x axes are each shown as linear.

## Scatterplot B

Replace these instructions with your second scatterplot, where the x axis is now presented on a logarithmic (base 10) scale.

## Faceted Scatterplot

Replace these instructions with your preferred scatterplot, now faceted by state into six individual, well-labeled plots.

## Results 2

Replace these instructions with a paragraph that adequately describes the key findings shown in your visualizations, in light of your research question.

# Comparison 3

## Research Question 3

Replace these instructions with your introductory paragraph for this comparison, including your research question, and your belief (prior to seeing the data) as to which direction the effect will take.

## Summaries 3

Replace these instructions with numerical summaries and visualizations of interest that are relevant to this analysis, and comment on any issues you observe.

## Confidence Intervals 3

### A t-based procedure

Replace these instructions with code for an ordinary least squares model to generate an appropriate t-based confidence interval.

### A bootstrap

Replace these instructions with code for a bootstrap confidence interval.

## Justification 3

Replace these instructions with a few sentences that specify the final confidence interval you've chosen, and why you chose it. Be sure to include any appropriate assumption checks that helped you make your decision.

## Results 3

Replace these instructions with a paragraph which includes a clear restatement of your research question, followed by a clear and appropriate response to your research question, motivated by your results. Interpret your chosen 90% confidence interval’s point estimate, endpoints and width in context. You should also reflect on your pre-existing belief about what would happen in light of these results.

## Limitations 3

Replace these instructions with a paragraph which summarizes the key limitations of your work in Comparison 3.

# Comparison 4

## Research Question 4

Replace these instructions with your introductory paragraph for this comparison, including your research question, and your belief (prior to seeing the data) as to which direction the effect will take.

## Summaries 4

Replace these instructions with numerical summaries and visualizations of interest that are relevant to this analysis, and comment on any issues you observe.

## Confidence Intervals 4

### A t-based procedure

Replace these instructions with code for an ordinary least squares model to generate an appropriate pooled-t confidence interval.

### A bootstrap

Replace these instructions with code for an appropriate bootstrap confidence interval.

## Justification 4

Replace these instructions with a few sentences that specify the final confidence interval you've chosen, and why you chose it. Be sure to include any appropriate assumption checks that helped you make your decision.

## Results 4

Replace these instructions with a paragraph which includes a clear restatement of your research question, followed by a clear and appropriate response to your research question, motivated by your results. Interpret your chosen 90% confidence interval’s point estimate, endpoints and width in context. You should also reflect on your pre-existing belief about what would happen in light of these results.

## Limitations 4

Replace these instructions with a paragraph which summarizes the key limitations of your work in Comparison 4.

# Reflection

## Most Important 

Replace these instructions with a paragraph answering the question: What was the most important thing you learned as a result of doing this project, and why?

## Most Challenging

Replace these instructions with a paragraph answering the question: What was the most challenging (or difficult) part of completing the Project, and how you were able to overcome whatever it was that was most challenging?

# AI Usage

Replace these instructions with an appropriate response, which might be ... In preparing this response, I made no use of AI outside of spell-check and code completion within RStudio.

# References

Provide a numbered list of your references.

1. Your first reference goes here.
2. Reference 2 would go here.

# Session Information

```{r}
xfun::session_info()
```

