- create an Rmarkdown document with “district” data (like this
one)
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.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(dplyr)
district<-read_excel("district.xls")
- create a new data frame with “DISTNAME”, “DPETSPEP” (percent special
education) and “DPFPASPEP” (money spent on special education). call the
dataframe whatever you want
new_data_frame <- district %>%
select (DISTNAME, DPETSPEP, DPFPASPEP)
- give me “summary()” statistics for both DPETSPEP and DFPASPEP. You
can summarize them separately if you want.
summary(new_data_frame)
## 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
- Which variable has missing values?
summary(new_data_frame$DPFPASPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.000 5.800 8.900 9.711 12.500 49.000 5
- remove the missing observations. How many are left overall?
clean_data<-new_data_frame |> drop_na()
summary(clean_data$DPFPASPEP)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 5.800 8.900 9.711 12.500 49.000
- Create a point graph (hint: ggplot + geom_point()) to compare
DPFPASPEP and DPETSPEP. Are they correlated?
ggplot(clean_data,aes(x=DPFPASPEP,y=DPETSPEP)) + geom_point()

- Do a mathematical check (cor()) of DPFPASPEP and DPETSPEP. What is
the result?
cor(clean_data$DPFPASPEP,clean_data$DPETSPEP)
## [1] 0.3700234
- How would you interpret these results? (No real right or wrong
answer – just tell me what you see)
- I THINK this means that there is a positive relationship, but
correlation isn’t strong because it should be plus/minus 1?