Skip to contents

Montana enrollment support in mtschooldata is strict and provenance-driven: only years with official OPI district + school files are exposed.

years <- get_available_years()
stopifnot(length(years) > 0)

enr_multi <- fetch_enr_multi(years, use_cache = TRUE)
latest_year <- max(years)
enr_latest <- fetch_enr(latest_year, use_cache = TRUE)

1. State total trend across supported years

state_trend <- enr_multi |>
  filter(is_state, subgroup == "total_enrollment", grade_level == "TOTAL") |>
  select(end_year, n_students) |>
  arrange(end_year)

state_trend
#>   end_year n_students
#> 1     2025     170033
#> 2     2026     167247
ggplot(state_trend, aes(x = end_year, y = n_students)) +
  geom_line(linewidth = 1) +
  geom_point(size = 2) +
  scale_x_continuous(breaks = state_trend$end_year) +
  labs(
    title = "Montana State Enrollment Across Supported Years",
    x = "End Year",
    y = "Students"
  ) +
  theme_minimal(base_size = 12)

2. Largest districts in the latest supported year

top_districts <- enr_latest |>
  filter(
    is_district,
    subgroup == "total_enrollment",
    grade_level == "TOTAL"
  ) |>
  arrange(desc(n_students)) |>
  select(district_name, n_students) |>
  slice_head(n = 10)

top_districts
#>       district_name n_students
#> 1     Billings Elem      10737
#> 2  Great Falls Elem       6668
#> 3      Billings H S       5408
#> 4     Missoula Elem       4962
#> 5       Helena Elem       4836
#> 6      Bozeman Elem       4587
#> 7      Missoula H S       3859
#> 8      Flathead H S       2944
#> 9    Kalispell Elem       2921
#> 10  Great Falls H S       2883
ggplot(top_districts, aes(x = reorder(district_name, n_students), y = n_students)) +
  geom_col(fill = "#2A6F97") +
  coord_flip() +
  labs(
    title = paste("Top 10 Districts in", latest_year),
    x = NULL,
    y = "Students"
  ) +
  theme_minimal(base_size = 12)

3. District vs school totals in the latest year

latest_wide <- fetch_enr(latest_year, tidy = FALSE, use_cache = TRUE)

parity_check <- data.frame(
  end_year = latest_year,
  district_total = sum(latest_wide$row_total[latest_wide$type == "District"], na.rm = TRUE),
  state_total = sum(latest_wide$row_total[latest_wide$type == "State"], na.rm = TRUE),
  school_rows = sum(latest_wide$type == "School")
)

parity_check
#>   end_year district_total state_total school_rows
#> 1     2026         167247      167247         613

The state total equals the sum of district totals in strict manifest mode, and school-level rows are available for the same year.