library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.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
district<-read_excel("district.xls")
#1. Below I am creating a new date frame using the district dataset to pull “DISTNAME”, “DPETSPEP” (percent special education) and “DPFPASPEP” (money spent on special education). The new data frame will be called special_ed.
# Creating a new data frame
special_ed <- district[, c("DISTNAME", "DPETSPEP", "DPFPASPEP")]
# View new data frame
head(special_ed)
## # A tibble: 6 × 3
## DISTNAME DPETSPEP DPFPASPEP
## <chr> <dbl> <dbl>
## 1 CAYUGA ISD 14.6 28.9
## 2 ELKHART ISD 12.1 8.8
## 3 FRANKSTON ISD 13.1 8.4
## 4 NECHES ISD 10.5 10.1
## 5 PALESTINE ISD 13.5 6.1
## 6 WESTWOOD ISD 14.5 9.4
#2 Below is a summary of the statistics for both DPETSPEP and DFPASPEP.
#Summarizing percentage of special education
summary(special_ed$DPETSPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 9.90 12.10 12.27 14.20 51.70
#Summarizing money spent on special education
summary(special_ed$DPFPASPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.000 5.800 8.900 9.711 12.500 49.000 5
#4 The variable with missing values is DPFPASPEP (money spent on special education). This is shown in the summary as 5 NA’s.
#5 Below I have removed the missing observations. There are now 1201 remaining observations.
special_ed_cleaned<-special_ed %>% filter(DPFPASPEP>0)
remaining_observations <- nrow(special_ed_cleaned)
#6 Below is a point graph to compare DPFPASPEP and DPETSPEP.
#Below is my point graph comparing DPFPASPEP and DPETSPEP
compare_two<-special_ed_cleaned %>% select(DISTNAME,DPFPASPEP,DPETSPEP)
ggplot(compare_two,aes(DPFPASPEP,DPETSPEP)) + geom_point()
#7 Numerical correlation between both DPFPASPEP and DPETSPEP
# Correlation between DPFPASPEP and DPETSPEP
correlation <- cor(compare_two$DPFPASPEP, compare_two$DPETSPEP, use = "complete.obs")
# Print the correlation
correlation
## [1] 0.371033
#8 I see a weak to moderate correlation. Point graphs slightly shows that higher spending is generally associated with a higher percentage of special education students, but the connection isn’t very tight.