R Markdown
# Running the packages first
library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.0 ✔ readr 2.1.6
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.2 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.1
## ── 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
# Set working directory
district<-read_excel("district.xls")
# Creating a new data frame with District name, special education percentage
# and money spent on special education
special_education<-district %>% select(DISTNAME,DPFPASPEP,DPETSPEP)
# Summary Statistics for DPETSPEP and DPFPASPEP
summary(special_education)
## DISTNAME DPFPASPEP DPETSPEP
## Length:1207 Min. : 0.000 Min. : 0.00
## Class :character 1st Qu.: 5.800 1st Qu.: 9.90
## Mode :character Median : 8.900 Median :12.10
## Mean : 9.711 Mean :12.27
## 3rd Qu.:12.500 3rd Qu.:14.20
## Max. :49.000 Max. :51.70
## NA's :5
# DPFPASPEP, money spent on special education has five missing values
# I will attempt to remove them below with this careful extraction power
# of na
special_education_new <- special_education %>% drop_na(DPFPASPEP)
#after dropping five missing values, we have 1,202 observations left
# Attemping to create a graph, though not required
# I am not sure if this is correct
ggplot(special_education_new,aes(x=DPETSPEP,y=DPFPASPEP)) + geom_point()

# Mathematical check
cor(special_education_new$DPETSPEP,special_education_new$DPFPASPEP)
## [1] 0.3700234
# Result is 0.3700234
# The mathematical check indicate a positive correlation, although not as
# strong as we would like it to be. The closer the mathematical check is to
# 1, the stronger the correlation, and the closer to zero the weaker.