Analysis

Setup

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.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ 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(janitor)

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
library(scales)

Attaching package: 'scales'

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

    discard

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

    col_factor
library(DT)

Import

I am importing the cleaned data.

# Importing the clean data
sped <- read_rds("data-processed/01-sped.rds")

sped |> head()

District percents table

I am creating a table of district percents.

district_percents_data <- sped |> 
  select(distname, cntyname, year, sped_percent) |> 
  pivot_wider(names_from = year, values_from = sped_percent)

I will now make a datatable.

district_percents_data |>
  datatable()

Data Takeaway: The percentage of special education students in Austin ISD increased from 10% in 2013 to 13.8% in 2023.

Choosing a chart to display data

Has the percentage of special education students in Texas changed since the benchmarking policy was dropped?

I am getting yearly percentages.

yearly_percent <- sped |> 
  group_by(year) |> 
  summarise(
    total_students = sum(all_count),
    total_sped = sum(sped_count)
  ) |> 
  mutate(sped_percent = ((total_sped / total_students) * 100) |> round_half_up(1))

yearly_percent

Now I am building the statewide percentage chart.

yearly_percent |>
  ggplot(aes(x = year, y = sped_percent)) +
  geom_col() +
  geom_text(aes(label = sped_percent, vjust = -.5))

Data takeaway: The statewide percentage of special education students has increased from 8.6% in 2013 to 12.9% in 2023.

Districts by benchmark and year

How many districts were above that arbitrary 8.5% benchmark before and after the changes?

I am counting districts by the audit flag.

flag_count_districts <- sped |> 
  count(year, audit_flag, name = "count_districts")

I am building the first exploratory chart.

flag_count_districts |> 
  ggplot(aes(x = year, y = count_districts, fill = audit_flag)) +
  geom_col()

I am building the grouped column version.

flag_count_districts |> 
  ggplot(aes(x = year, y = count_districts, fill = audit_flag)) +
  geom_col(position = "dodge")

Now, I am visualizing as a line.

flag_count_districts |> 
  ggplot(aes(x = year, y = count_districts, group = audit_flag)) +
  geom_line(aes(color = audit_flag)) +
  ylim(0,1000)

Data takeaway: Before the change, there were about 600 districts above the arbitrary 8.5% benchmark. After the change, the number grew to almost 1,000 districts in 2023.

Local districts

How have local districts changed?

sped |> head()

I am looking at local districts.

# Bastrop

sped |> 
  filter(cntyname == "BASTROP") |> 
  ggplot(aes(x = year, y = sped_percent, group = distname)) +
  geom_line(aes(color = distname)) +
  geom_point(aes(color = distname))

Data takeaway: The percentages of special education students in Bastrop county school districts have increased since the change.

Now I am doing the same for the other three counties, each in their own code chunk: Hays, Travis and Williamson.

# Hays

sped |> 
  filter(cntyname == "HAYS") |> 
  ggplot(aes(x = year, y = sped_percent, group = distname)) +
  geom_line(aes(color = distname)) +
  geom_point(aes(color = distname))

Data takeaway: The percentages of special education students in Hays county school districts have increased since the change.

# Travis

sped |> 
  filter(cntyname == "TRAVIS") |> 
  ggplot(aes(x = year, y = sped_percent, group = distname)) +
  geom_line(aes(color = distname)) +
  geom_point(aes(color = distname))

Data takeaway: The percentages of special education students in Travis county school districts have increased since the change.

# Williamson

sped |> 
  filter(cntyname == "WILLIAMSON") |> 
  ggplot(aes(x = year, y = sped_percent, group = distname)) +
  geom_line(aes(color = distname)) +
  geom_point(aes(color = distname))

Data takeaway: The percentages of special education students in Williamson county school districts have increased since the change.

Exporting

I am exporting my data for Datawrapper.

# Exporting my data for Datawrapper

yearly_percent |>
  write_csv("data-processed/yearly_percent.csv")

Datawrapper graphic