#load packages
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
#set working directory
setwd("~/Applied Quantitative Methods Class/W3 9.8.2026")

#load in data
district<-read_excel("district.xls")
summary(district$DPETECOP)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   47.95   61.90   60.75   77.15  100.00
hist(district$DPETECOP)

clean <- district[!is.na(district$DPETECOP) & 
                   !is.na(district$DA0AT21R) & 
                   district$DA0AT21R >= 0, ]
plot(clean$DPETECOP, clean$DA0AT21R,
     xlab = "% Economically Disadvantaged",
     ylab = "Attendance Rate",
     main = "Economic Disadvantage vs. Attendance Rate")

cor(clean$DPETECOP, clean$DA0AT21R)
## [1] -0.3564171