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
wd<-getwd()
district<-read_xls("district.xls")
###2) create a new data frame with "DISTNAME", "DPETSPEP" (percent special education) and "DPFPASPEP" (money spent on special education). call the dataframe whatever you want
district_data_frame<-district %>% select( "DISTNAME", "DPETSPEP", "DPFPASPEP")
head(district_data_frame)
## # 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
###3) give me "summary()" statistics for both DPETSPEP and DFPASPEP. You can summarize them separately if you want.
summary(district$"DPETSPEP")
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 9.90 12.10 12.27 14.20 51.70
summary(district$"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) Which variable has missing values?
###THE VARIABLE "DPFPASPEP"(MONEY SPENT ON EDUCATION) HAS 5 MISSING VALUES
###5) remove the missing observations. How many are left overall?
###OVERALL THERE ARE ONLY 1201 OBSERVATIONS LEFT OF THE 1207 TOTAL OBSERVATIONS
district_data_frame_cleaned<- district_data_frame %>% filter(DPFPASPEP>0)
summary(district_data_frame_cleaned$"DPFPASPEP")
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.200 5.800 8.900 9.719 12.500 49.000
###6) Create a point graph (hint: ggplot + geom_point()) to compare DPFPASPEP and DPETSPEP. Are they correlated?
###YES, GRAPH SHOWS THERE IS A POSITIVE CORRELATION
compare_two<-district_data_frame_cleaned %>% select(DISTNAME,DPFPASPEP,DPETSPEP)
compare_two<-compare_two %>% filter(DPFPASPEP>0)
ggplot(compare_two,aes(DPFPASPEP,DPETSPEP)) + geom_point()

###7) Do a mathematical check (cor()) of DPFPASPEP and DPETSPEP. What is the result?
cor(district_data_frame_cleaned$"DPETSPEP",district_data_frame_cleaned$"DPFPASPEP")
## [1] 0.371033
###8) How would you interpret these results? (No real right or wrong answer -- just tell me what you see)
###THE CORRELATION SHOWS IT IS POSITIVE, HOWEVER SINCE IT IS IN THE .30'S AND UNDER THE .40-.80 RANGE, I SAY IT WOULD BE CONSIDERED A WEAK CORRELATION.