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.4 ✔ 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
library(readxl)
district_data<-read_excel("district.xls")
new_data<-district_data[, c("DISTNAME","DPETSPEP","DPFPASPEP")]
summary(new_data$DPETSPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 9.90 12.10 12.27 14.20 51.70
summary(new_data$DPFPASPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.000 5.800 8.900 9.711 12.500 49.000 5
sum(is.na(new_data$DPETSPEP))
## [1] 0
sum(is.na(new_data$DPFPASPEP))
## [1] 5
The variable DPFPASPEP has 5 missing values
clean_data<-na.omit(new_data)
nrow(clean_data)
## [1] 1202
There are 1202 observations left
library(ggplot2)
ggplot(new_data, aes(x=DPFPASPEP, y=DPETSPEP)) +geom_point()
## Warning: Removed 5 rows containing missing values or values outside the scale range
## (`geom_point()`).
The graph would suggest there is a correlation between x and y
cor(new_data$DPFPASPEP, new_data$DPETSPEP, use="complete.obs")
## [1] 0.3700234
According to the mathematical check, there is a moderate positive correlation between the two
I interpret the results as spending increases, the percentage of special education students tends to increase. However, the relationship is not very strong