DAM5_Ayman

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0     ✔ purrr   1.0.1
✔ tibble  3.2.1     ✔ dplyr   1.1.3
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.3     ✔ forcats 0.5.2
Warning: package 'tibble' was built under R version 4.2.3
Warning: package 'tidyr' was built under R version 4.2.3
Warning: package 'purrr' was built under R version 4.2.3
Warning: package 'dplyr' was built under R version 4.2.3
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(readxl)
library(kableExtra)
Warning: package 'kableExtra' was built under R version 4.2.3

Attaching package: 'kableExtra'

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

    group_rows

Task 1

data1 <- as_tibble(read_xlsx("data.xlsx", 
                    range = "A9:E31"))
data1
# A tibble: 22 × 5
    Year Jurisdiction  `All students` `Average scale score` `Standard deviation`
   <dbl> <chr>         <chr>                          <dbl>                <dbl>
 1  2022 National pub… All students                    273.                 39.0
 2  2022 New York      All students                    274.                 41.5
 3  2019 National pub… All students                    281.                 39.8
 4  2019 New York      All students                    280.                 42.1
 5  2017 National pub… All students                    282.                 38.9
 6  2017 New York      All students                    282.                 40.0
 7  2015 National pub… All students                    281.                 36.9
 8  2015 New York      All students                    280.                 36.6
 9  2013 National pub… All students                    284.                 36.4
10  2013 New York      All students                    282.                 36.2
# ℹ 12 more rows

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 National public All students 272 38
2000 New York All students 271 39
2003 National public All students 276 36
2003 New York All students 280 37
2005 National public All students 278 36
2005 New York All students 280 36
2007 National public All students 280 36
2007 New York All students 280 36
2009 National public All students 282 36
2009 New York All students 283 37
2011 National public All students 283 36
2011 New York All students 280 35
2013 National public All students 284 36
2013 New York All students 282 36
2015 National public All students 281 37
2015 New York All students 280 37
2017 National public All students 282 39
2017 New York All students 282 40
2019 National public All students 281 40
2019 New York All students 280 42
2022 National public All students 273 39
2022 New York All students 274 42

Task 3

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

Task 4

ggplot(data = data1, aes(x = Year, y = `Average scale score`)) +
  geom_line(aes(color = Jurisdiction)) +
  geom_line(mapping = aes(x=Year, y = 262, color = "Basic"), linetype=2) +
  geom_line(mapping = aes(x=Year, y = 299, color = "Proficient"), linetype=2) +
  geom_line(mapping = aes(x=Year, y = 333, color = "Advanced"), linetype=2) + labs(title = "Average Scores for New York and the Nation (Public)") +
  theme_gray() +
  theme(legend.position = "right") +
  scale_color_manual(name="", breaks=c("National public", "New York", "Advanced", "Proficient", "Basic"), labels=c("National public", "New York", "Advanced", "Proficient", "Basic"), values=c("purple", "brown", "red", "green", "blue"))

The plot shows that both nationally and from a New York perspective, scores are between the basic and proficient level. We can also see between 2010 and around 2017 average scores in New York are lower then the Nation scores. But the scores both seem to be somewhat close to each other hence showing not a big difference.

Task 5

# Find the difference between National and New York 
# 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(NY_Nat_SD = ((`Average scale score`[2] - `Average scale score`[1]) / `Standard deviation`[1] )) 

# print difference in SD between New York and National
round(data5$NY_Nat_SD[1], 2) # rounded to two decimal places
[1] 0.03

In 2022, the average score of eighth-grade students in New York was 274, slightly higher than the average score of 273 for students in the nation's public schools. This difference was only 0.03 of a standard deviation of the distribution of NAEP scores in 8th grade mathematics nationally.

Task 6

# Find the difference between New York in 2000 and 2019 and divide by SD for 2022
data6 <- data1 |>
  filter(Jurisdiction == "New York") |> # Select New York data only
  filter(Year == 2022 | Year == 2019 |  Year == 2000) |> # Select the years 2000, 2019, and 2022
  mutate(NY_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$NY_DiffSince2022_SD[2], 2) # Round the difference between 2019 and 2022 to two decimal places
[1] 0.15

The average score for students in New York in 2022 (274) was lower than their average score in 2019 (280) by 0.15 of a standard deviation and was not different from their average score in 2000 (271).

Task 7

data7 <- as_tibble(read_xlsx("damnewdata.xlsx", range = "A9:E42")) 

# 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 New York Eligible 255 39
2000 New York Not eligible 284 31
2003 New York Eligible 262 35
2003 New York Not eligible 293 31
2005 New York Eligible 267 36
2005 New York Not eligible 291 32
2007 New York Eligible 268 35
2007 New York Not eligible 292 32
2009 New York Eligible 270 37
2009 New York Not eligible 293 32
2011 New York Eligible 269 34
2011 New York Not eligible 293 32
2013 New York Eligible 269 35
2013 New York Not eligible 293 33
2015 New York Eligible 271 35
2015 New York Not eligible 292 35
2017 New York Eligible 269 38
2017 New York Not eligible 294 38
2019 New York Eligible 266 40
2019 New York Not eligible 294 39
2022 New York Eligible 262 39
2022 New York Not eligible 290 39

Task 8

newdata7 <- data7 %>%
  select(-`Standard deviation`) %>%
  pivot_wider(names_from = `National School Lunch Program eligibility, 3 categories`, values_from = `Average scale score`)
  

ggplot(
  data = newdata7) +
  geom_line(mapping = aes(x=Year, y = `Eligible`, color="Eligible")) +
  geom_line(mapping = aes(x=Year, y = `Not eligible`, color="Not eligible")) +
  labs(
    title = "Trend in Students Eligible and Not Eligible for NSLP",
    subtitle = "Main NAEP: 2000 - 2022",
    y = "Eligible/Not Eligible"
  ) +
  geom_line(mapping = aes(x=Year, y = 262, color = "Basic"), linetype=2) +
  geom_line(mapping = aes(x=Year, y = 299, color = "Proficient"), linetype=2) +
  geom_line(mapping = aes(x=Year, y = 333, color = "Advanced"), linetype=2) +
  theme_gray() +
  theme(legend.position = "right") +
  scale_color_manual(name="", breaks=c("Eligible", "Not eligible", "Advanced", "Proficient", "Basic"), labels=c("Eligible for subsidized lunch", "Not eligible for subsidized lunch", "Advanced", "Proficient", "Basic"), values=c("purple", "brown", "red", "green", "blue"))

Task 9

In 2022, students who were eligible for the National School Lunch Program (NSLP) had an average score that was about 28 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 a bit higher than they were in 2000. I also noticed that this gap was similar (28 points) in 2019 just prior the pandemic and remained about 28 points in 2022.

Task 10

data10 <- as_tibble(read_xlsx("damdisability.xlsx", range = "A9:E15")) 

# 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 New York Identified as students with disabilities 230.8 41.0 -1.2
2000 New York Not identified as students with disabilities 275.5 35.8 0.0
2019 New York Identified as students with disabilities 244.5 34.9 -0.9
2019 New York Not identified as students with disabilities 288.2 39.3 0.4
2022 New York Identified as students with disabilities 244.3 35.7 -0.9
2022 New York Not identified as students with disabilities 280.5 39.9 0.1

Task 11

In 2022, average scores for those who identified as students with a disability was about 36 points or about 1.01 standard deviation lower than average scores for those not identified as students with a disability. This gap is smaller than the gap of about 45 points (1.24 SD) in 2000 and about 44 points (1.2 SD) in 2019.

Task 12

data12 <- as_tibble(read_xlsx("damstudent.xlsx", range = "A9:E11")) 

# 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 New York ELL 231 29
2022 New York Not ELL 278 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.168869

Task 13

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