Loading the Data

setwd("~/Documents/R Files/Homework 3")
district <- read_excel("district.xls")

2) Create a new data frame with “DISTNAME”, “DPETSPEP” (percent special education) and “DPFPASPEP”

special_ed <- district[, c("DISTNAME", "DPETSPEP", "DPFPASPEP")]
head(special_ed)
# 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 a “summary()” statistics for both DPETSPEP and DFPASPEP.

summary(special_ed$DPETSPEP)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00    9.90   12.10   12.27   14.20   51.70 
summary(special_ed$DPFPASPEP)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.     NAs 
  0.000   5.800   8.900   9.711  12.500  49.000       5 

4) Which variable has missing values?

The variable DPFPASPEP has missing values, with 5 missing observations.

5) Remove the missing observations. How many are left overall?

special_ed_clean <- drop_na(special_ed)
cat(nrow(special_ed_clean))
1202

6) Create a point graph to compare DPFPASPEP and DPETSPEP. Are they correlated?

ggplot(special_ed_clean, aes(x = DPETSPEP, y = DPFPASPEP)) +
  geom_point(shape = 21, fill = "black", color = "darkred", size = 2.5) +
  labs(
    title = "Special Education Spending vs. Percent Special Education",
    x = "Percent Special Education",
    y = "Special Education Spending"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(hjust = 0.5)
  )

The graph appears to show a weak positive relationship between the two variables.

7) Do a mathematical check of DPFPASPEP and DPETSPEP. What is the result?

cat(cor(special_ed_clean$DPFPASPEP, special_ed_clean$DPETSPEP))
0.3700234

8) How would you interpret these results?

The results suggest that there is a positive relationship between the percentage of students in special education and the amount of money spent on special education. As the percentage of special education students increases, spending also tends to increase. However, the relationship is not perfect, which means that there are other factors that likely influence special education spending as well.