DAM5_An

Task 0

Task 1

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.3     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ 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
library(readxl)
library(kableExtra)

Attaching package: 'kableExtra'

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

    group_rows
data1 <- read.csv("/Users/anweshanadhikari/Downloads/NDECoreExcel_Mathematics, Grade 8, All students_20231202012416.csv")

data1
   Year    Jurisdiction All.students Average.scale.score Standard.deviation
1  2022 National public All students                 273                 39
2  2022      California All students                 270                 42
3  2019 National public All students                 281                 40
4  2019      California All students                 276                 42
5  2017 National public All students                 282                 39
6  2017      California All students                 277                 41
7  2015 National public All students                 281                 37
8  2015      California All students                 275                 38
9  2013 National public All students                 284                 36
10 2013      California All students                 276                 38
11 2011 National public All students                 283                 36
12 2011      California All students                 273                 39
13 2009 National public All students                 282                 36
14 2009      California All students                 270                 39
15 2007 National public All students                 280                 36
16 2007      California All students                 270                 39
17 2005 National public All students                 278                 36
18 2005      California All students                 269                 39
19 2003 National public All students                 276                 36
20 2003      California All students                 267                 39
21 2000 National public All students                 272                 38
22 2000      California All students                 260                 41

Task 2

Code source: https://rpubs.com/HoffmanMiddlebury/1122249

# 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(260,300)

Task 4

Basic<- 262
Proficient<- 299
Advanced<- 333

ggplot(data = data1, aes(x = Year, y = `Average.scale.score`)) +
  geom_line(aes(color = Jurisdiction)) +
  geom_hline(yintercept = Basic, linetype = "dashed", color = "#248f24") +
  geom_hline(yintercept = Proficient, linetype = "dashed", color = "#248f24") +
  geom_hline(yintercept = Advanced, linetype = "dashed", color = "#248f24") +
  annotate("text", x = max(data1$Year), y = Basic+1.3, label = "Basic", hjust = 1.1, color = "#248f24") +
  annotate("text", x = max(data1$Year), y = Proficient+1.3, label = "Proficient", hjust = 1.1, color = "#248f24") +
  annotate("text", x = max(data1$Year), y = Advanced+1.3, label = "Advanced", hjust = 1.1, color = "#248f24") +
  labs(
    title = "Trend in Grade 8 Mathematics Average Scale Scores in California",
    subtitle = "Main NAEP: 2000 - 2022",
    x = "Year",
    y = "Average Scale Score",
    caption = "Horizontal lines represent Basic, Proficient, and Advanced cut scores"
  ) +
  theme_minimal() 

  ylim(260,300)
<ScaleContinuousPosition>
 Range:  
 Limits:  260 --  300

Task 5

Code source: https://rpubs.com/HoffmanMiddlebury/1122249

# Find the difference between National and Illinois 
# and divide by SD for National in 2022 (The [1] & [2] refer to row numbers)

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] )) 

# print difference in SD between Illinois and National
round(data5$Ca[1], 2) # rounded to two decimal places
[1] -0.08

In 2022, the average score of eighth-grade students in California was 270, slightly lower than the average score of 273 for students in the nation’s public schools. This difference was only -0.08 of a standard deviation of the distribution of NAEP scores in 8th grade mathematics nationally.

Task 6

Code source: https://rpubs.com/HoffmanMiddlebury/1122249

# Find the difference between Illinois in 2000 and 2019 and divide by SD for 2022
data6 <- data1 |>
  filter(Jurisdiction == "California") |> # Select Illinois data only
  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] ))
# Note that while the average for both 2000 and 2022 are 275,
# they are trivially different: 274.5487 in 2000 and 275.1951
# The important difference in SD is between 2019 and the other two years here
round(data6$CA_DiffSince2022_SD[2], 2) # Round the difference between 2019 and 2022 to two decimal places
[1] 0.14

The average score for students in California in 2022 (270) was lower than their average score in 2019 (276) by 0.14 of a standard deviation and was higher than their average score in 2000 (260).

Task 7

Code source: https://rpubs.com/HoffmanMiddlebury/1122249

data7 <- read.csv("/Users/anweshanadhikari/Downloads/NDECoreExcel_Mathematics, Grade 8, National School Lunch Progra_20231202014940.csv")

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

##formatting the data
#converting column with two unique values to multiple columns
data7_post <- data7 %>%
  mutate(NotEligible_Average.scale.score = ifelse(National.School.Lunch.Program.eligibility..3.categories == "Not eligible", Average.scale.score, NA),
          Eligible_Average.scale.score= ifelse(National.School.Lunch.Program.eligibility..3.categories == "Eligible", Average.scale.score, NA),
         NotEligible_SD = ifelse(National.School.Lunch.Program.eligibility..3.categories == "Not eligible", Standard.deviation, NA),
         Eligible_SD = ifelse(National.School.Lunch.Program.eligibility..3.categories == "Eligible", Standard.deviation, NA))


#removing columns that are no longer necessary
data7_post <- data7_post%>% select(-c("National.School.Lunch.Program.eligibility..3.categories", "Average.scale.score", "Standard.deviation"))

#merging rows with the same year, so that eligible and non-eligible data for the same year will be in a single row
data7_new <- data7_post %>%
  group_by(Year) %>%
  summarize(
    NotEligible_Average.scale.score = mean(NotEligible_Average.scale.score, na.rm = TRUE),
    Eligible_Average.scale.score = mean(Eligible_Average.scale.score, na.rm = TRUE),
    NotEligible_SD = mean(NotEligible_SD, na.rm = TRUE),
    Eligible_SD = mean(Eligible_SD, na.rm = TRUE)
  ) %>%
  ungroup()

Task 9

ggplot(data7_new, aes(x = Year)) +
  geom_line(aes(y = Eligible_Average.scale.score, colour = "Eligible")) + 
  geom_line(aes(y = NotEligible_Average.scale.score, colour = "Not Eligible")) +
  scale_color_manual(values = c("black", "red"), name = "NSLP Eligibility") +
  geom_hline(yintercept = Basic, linetype = "dashed", color = "#248f24") +
  geom_hline(yintercept = Proficient, linetype = "dashed", color = "#248f24") +
  geom_hline(yintercept = Advanced, linetype = "dashed", color = "#248f24") +
  annotate("text", x = max(data1$Year), y = Basic+0.5, label = "Basic", hjust = 13.1, color = "#248f24") +
  annotate("text", x = max(data1$Year), y = Proficient+0.5, label = "Proficient", hjust = 7.6, color = "#248f24") +
  annotate("text", x = max(data1$Year), y = Advanced+0.5, label = "Advanced", hjust = 7.2, color = "#248f24") +
  
  labs(
    title = "Trend in Grade 8 Mathematics Average Scores by NSLP Eligibility",
    subtitle = "Main NAEP: 2003 - 2022",
    x = "Year",
    y = "Average Scale Score",
    caption = "The Horizontal lines represent Basic, Proficient, and Advanced cut scores"
  ) +
  theme_minimal() 

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, though the averages for both students Eligible for NSLP and for those not eligible for NSLP were significantly higher than they were in year 2000 (240 and 269 respectively). I also noticed that this gap was of 36 points in 2019 just prior the pandemic and it remained the same post-pandemic in 2022.

Task 10

Code source: https://rpubs.com/HoffmanMiddlebury/1122249

data10 <- read.csv("/Users/anweshanadhikari/Downloads/NDECoreExcel_Mathematics, Grade 8, Disability status of student_20231202022835.csv")

# Arrange by year: 2000, 2019, 2022
# And use the 2000 scores for those not identified as students with disabilities as the baseline
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 213 43 -1.3
2000 California Not identified as students with disabilities 264 38 0.0
2019 California Identified as students with disabilities 242 38 -0.6
2019 California Not identified as students with disabilities 280 40 0.4
2022 California Identified as students with disabilities 234 40 -0.8
2022 California Not identified as students with disabilities 274 40 0.3

Task 11

In 2022, average scores for those who identified as students with a disability were 40 points or 1.1 standard deviation lower than average scores for those not identified as students with a disability. This gap is smaller than the gap of 51 points (-1.3 SD) in 2000 and 38 points (1.0 SD) in 2019.

Task 12

Code source: https://rpubs.com/HoffmanMiddlebury/1122249

## Task 12
data12 <- read.csv("/Users/anweshanadhikari/Downloads/NDECoreExcel_Mathematics, Grade 8, Status as English learner, 2_20231202023922.csv")
Warning in read.table(file = file, header = header, sep = sep,
quote = quote, : incomplete final line found by readTableHeader on
'/Users/anweshanadhikari/Downloads/NDECoreExcel_Mathematics, Grade 8, Status as
English learner, 2_20231202023922.csv'
# 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
# Calculate gap in standard deviation units (Not ELL SD as baseline)
gapELL <- ((data12$`Average.scale.score`[1] - data12$`Average.scale.score`[2]) / data12$`Standard.deviation`[2])
gapELL
[1] -1.025

Task 13

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