DAM5_kelly

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.1     ✔ purrr   1.0.1
✔ tibble  3.1.8     ✔ dplyr   1.1.0
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.4     ✔ forcats 1.0.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(readxl)
library(kableExtra)

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
library(ggplot2)

Task 1

data1 <- read_excel("NDECore_California.xlsx")
data1
# A tibble: 22 × 5
    Year Jurisdiction    `All students` `Average scale score` Standard deviati…¹
   <dbl> <chr>           <chr>                          <dbl>              <dbl>
 1  2022 National public All students                    273.               39.0
 2  2022 California      All students                    270.               41.6
 3  2019 National public All students                    281.               39.8
 4  2019 California      All students                    276.               41.9
 5  2017 National public All students                    282.               38.9
 6  2017 California      All students                    277.               41.4
 7  2015 National public All students                    281.               36.9
 8  2015 California      All students                    275.               38.1
 9  2013 National public All students                    284.               36.4
10  2013 California      All students                    276.               38.2
# … with 12 more rows, and abbreviated variable name ¹​`Standard deviation`

Task 2

# Task 2
data1 |>
  arrange(data1, Year) |> # arrange by year 
  kable(digits = 0) |> # set to zero decimal places
  kable_styling()
Year Jurisdiction All students Average scale score Standard deviation
2000 California All students 260 41
2000 National public All students 272 38
2003 California All students 267 39
2003 National public All students 276 36
2005 California All students 269 39
2005 National public All students 278 36
2007 California All students 270 39
2007 National public All students 280 36
2009 California All students 270 39
2009 National public All students 282 36
2011 California All students 273 39
2011 National public All students 283 36
2013 California All students 276 38
2013 National public All students 284 36
2015 California All students 275 38
2015 National public All students 281 37
2017 California All students 277 41
2017 National public All students 282 39
2019 California All students 276 42
2019 National public All students 281 40
2022 California All students 270 42
2022 National public All students 273 39

Task 3

ggplot(data = data1, aes(x = Year, y = `Average scale score`)) +
  geom_line(aes(color = Jurisdiction)) +
  ylim(250,300)

Task 4

cut_scores <- data.frame(
  Level = c("Basic", "Proficient", "Advanced"),
  Score = c(262, 299, 333))


ggplot(data = data1, aes(x = Year, y = `Average scale score`)) +
  geom_line(aes(color = Jurisdiction)) +
  geom_hline(data = cut_scores, aes(yintercept = Score, color = Level), 
             linetype = "dashed") +
  labs(title = "Trend in Grade 8 Mathematics Average Scores",
       subtitle = "2000 - 2022",
       x = "Year",
       y = "Average Scale Score",
       color = "Performance Level") +
  theme_minimal() +
  guides(linetype = "none")  

This figure shows the average math scores for California compared to the national public average and the NAEP cut scores for basic, proficient and advanced. California’s scores are consistently below the national average but the gap begins to close in the most recent years. The California and national average scores are both above basic and below proficient, with the exception of the year 2000, when the california average was below the basic threshold.

Task 5

data5 <- data1 |> 
  filter(Year == 2022) |> # Select two rows of data (2022 only)
  mutate(CA_Nat_SD = ((`Average scale score`[2] - `Average scale score`[1]) / `Standard deviation`[1] )) 

round(data5$CA_Nat_SD[1], 2) # rounded to two decimal places
[1] -0.09

In 2022, the average eight-grade math score in California was about 270 whcih is slightly lower than the national average of approximately 273. The average California score is 0.09 of a standard deviation lower than the national distribution of 8th grade math scores.

Task 6

data6 <- data1 |>
  filter(Jurisdiction == "California") |> 
  filter(Year == 2022 | Year == 2019 |  Year == 2000) |> # Select the years 2000, 2019, and 2022
  mutate(CA_DiffSince2022_SD = ((`Average scale score` - `Average scale score`[1]) / `Standard deviation`[1] ))

round(data6$CA_DiffSince2022_SD[2], 2) 
[1] 0.14
round(data6$CA_DiffSince2022_SD[3], 2) 
[1] -0.24

The average California math score 2022 was about 270 which is lower than the California average score of ~276 in 2019. The difference was 0.14 of a standard deviation. The average score in 2022 was higher than the California average score of ~260 in 2000. The difference was 0.24 of a standard deviation.

Task 7

#read in the Excel file from the A9 to E42 cell in the Excel file 
data7 <- read_excel("NDE_CA_Lunch.xlsx") 

# Drop all rows where "Information not available"
data7 <- data7 |>
  filter(`National School Lunch Program eligibility, 3 categories` !=  "Information not available") 

# Convert Average and SD from characters to numbers (due to the missing data in the original data)
data7$`Average scale score` <- as.numeric(data7$`Average scale score`)
data7$`Standard deviation` <- as.numeric(data7$`Standard deviation`)

# Print the data in order from 2000 to 2022
data7 |>
  arrange(Year) |> # arrange by year 
  kable(digits = 0) |> # set to zero decimal places
  kable_styling()
Year Jurisdiction National School Lunch Program eligibility, 3 categories Average scale score Standard deviation
2000 California Eligible 240 36
2000 California Not eligible 269 40
2003 California Eligible 251 35
2003 California Not eligible 281 38
2005 California Eligible 254 35
2005 California Not eligible 282 37
2007 California Eligible 257 35
2007 California Not eligible 283 37
2009 California Eligible 258 35
2009 California Not eligible 285 39
2011 California Eligible 260 36
2011 California Not eligible 288 38
2013 California Eligible 264 35
2013 California Not eligible 293 36
2015 California Eligible 264 35
2015 California Not eligible 293 36
2017 California Eligible 262 36
2017 California Not eligible 296 41
2019 California Eligible 262 37
2019 California Not eligible 298 40
2022 California Eligible 256 36
2022 California Not eligible 292 41

Task 8

ggplot(data = data7, aes(x = Year, y = `Average scale score`, color = `National School Lunch Program eligibility, 3 categories`)) +
  geom_line() +
  geom_hline(data = cut_scores, aes(yintercept = Score, color = Level), 
             linetype = "dashed") +
  labs(title = "Trend in California Grade 8 Mathematics Average Scores",
       subtitle = "By Free Lunch Eligibility",
       x = "Year",
       y = "Average Scale Score",
       color = "Performance Level") +
  theme_minimal() +
  guides(linetype = "none")  

Task 9

The California summary states that “In 2022, students who were eligible for the National School Lunch Program (NSLP) had an average score that was 36 points lower than that for students who were not eligible. This performance gap was not significantly different from that in 2000 (29 points).”

I noticed that prior to the pandemic (in 2019) the gap was almost exactly the same as after the pandemic. Eligible students, on average, scored about 36 points lower than students who were not eligible.

Task 10

## Task 10
data10 <- read_excel("NDE_CA_disability.xlsx")

data10 <- data10 |>
  arrange(Year) |>
  mutate(SPED_DiffSince2000_SD = ((`Average scale score` - `Average scale score`[2]) / `Standard deviation`[2] )) 

# Print this dataset
data10 |>   
  kable(digits = 1) |> # set to one decimal place
  kable_styling()
Year Jurisdiction Disability status of student, including those with 504 plan Average scale score Standard deviation SPED_DiffSince2000_SD
2000 California Identified as students with disabilities 212.5 42.8 -1.3
2000 California Not identified as students with disabilities 263.8 38.3 0.0
2019 California Identified as students with disabilities 241.7 37.8 -0.6
2019 California Not identified as students with disabilities 280.0 40.4 0.4
2022 California Identified as students with disabilities 234.2 39.9 -0.8
2022 California Not identified as students with disabilities 274.2 39.7 0.3

Task 11

In 2022, average scores for students identified as having a disability were 40 points or 1.04 standard deviations lower than average scores for those not identified as students with a disability. This gap is smaller than the gap of 51 points (1.34 SD) in 2000 and smaller than the gap of 38 points (1 SD) in 2019.

Task 12

data12 <- read_excel("NDE_CA_Language.xlsx") 

# Print this dataset
data12 |>   
  kable(digits = 0) |> # set to one decimal places
  kable_styling()
Year Jurisdiction Status as English learner, 2 categories Average scale score Standard deviation
2022 California ELL 236 31
2022 California Not ELL 277 40

Task 13

In 2022, average math scores for English learners were 41 points or more than one standard deviation lower than average scores for those not identified as English learners.