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.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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)
library(dplyr)
district <- read_excel("C:/Users/carmo/Downloads/district.xls")
filtered_district <- subset(district, select = c(DISTNAME, DPETSPEP, DPFPASPEP))
summary(filtered_district)
## DISTNAME DPETSPEP DPFPASPEP
## Length:1207 Min. : 0.00 Min. : 0.000
## Class :character 1st Qu.: 9.90 1st Qu.: 5.800
## Mode :character Median :12.10 Median : 8.900
## Mean :12.27 Mean : 9.711
## 3rd Qu.:14.20 3rd Qu.:12.500
## Max. :51.70 Max. :49.000
## NA's :5
#After performing the summary function on the filtered data set, we can see that DPFPASPEP, or the money spent on special education, has missing values.
#In order to remove the missing values, I will use “drop_na”.
clean_filtered <- drop_na(filtered_district)
#After removing the N/A’s from the dataset, there are 1205 observations.
library(ggplot2)
ggplot(clean_filtered, aes(x = DPETSPEP, y = DPFPASPEP)) + geom_point(color = "blue", size = 1)
cor(clean_filtered$DPETSPEP, clean_filtered$DPFPASPEP, method = "pearson")
## [1] 0.3700234
cor(clean_filtered$DPETSPEP, clean_filtered$DPFPASPEP, method = "spearman")
## [1] 0.346629
cor(clean_filtered$DPETSPEP, clean_filtered$DPFPASPEP, method = "kendall")
## [1] 0.2392367
#After running correlation using the three different methods and observing the point graph, it seems as though there is a minor positive correlation between the two variables.