#create an Rmarkdown document with "district" data
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")
view(district)
#create a new data frame with "DISTNAME", "DPETSPEP" (percent special education) and "DPFPASPEP" (money spent on special education). call the data frame whatever you want
school_data <-district %>% select(DISTNAME, DPETSPEP, DPFPASPEP)
head(school_data)
## # 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
# give me "summary()" statistics for both DPETSPEP and DFPASPEP. You can summarize them separately if you want.
summary(school_data$DPETSPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 9.90 12.10 12.27 14.20 51.70
summary(school_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
# Which variable has missing values?
#DPFPASPEP has the missing values
# remove the missing observations. How many are left overall?
school_data2 <-school_data %>% filter(!is.na(DPFPASPEP))
#1202 observations
# Create a point graph (hint: ggplot + geom_point()) to compare DPFPASPEP and DPETSPEP. Are they correlated?
ggplot(school_data2,aes(x=DPFPASPEP, y=DPETSPEP)) + geom_point()

# Do a mathematical check (cor()) of DPFPASPEP and DPETSPEP. What is the result?
cor(school_data2$DPFPASPEP, school_data2$DPETSPEP)
## [1] 0.3700234