Skip to contents

Downloads and processes enrollment data from the West Virginia Department of Education (WVDE). Combines grade-level data from WVDE School Finance PDFs with demographic data from WVDE School Composition files. When WVDE PDF files are unavailable for a year, district/state grade totals are built from the bundled School Composition workbooks instead.

Usage

fetch_enr(end_year, tidy = TRUE, use_cache = TRUE)

Arguments

end_year

A school year. Year is the end of the academic year - eg 2025-26 school year is year '2026'. Valid values: 2011-2026.

tidy

If TRUE (default), returns data in long (tidy) format with subgroup column. If FALSE, returns wide format (grade-level only, no demographics).

use_cache

If TRUE (default), uses locally cached data when available. Set to FALSE to force re-download from WVDE.

Value

Data frame with enrollment data. Wide format includes columns for district_id, district_name, and enrollment counts by grade. Tidy format includes grade-level rows (subgroup = "total_enrollment") and demographic rows (white, black, hispanic, asian, native_american, multiracial, pacific_islander, male, female, special_ed, econ_disadv, lep).

Examples

if (FALSE) { # \dontrun{
# Get 2025 enrollment data (2024-25 school year)
enr_2025 <- fetch_enr(2025)

# Get wide format (grade-level only)
enr_wide <- fetch_enr(2025, tidy = FALSE)

# Force fresh download (ignore cache)
enr_fresh <- fetch_enr(2025, use_cache = FALSE)

# Filter to specific county
kanawha <- enr_2025 |>
  dplyr::filter(district_name == "KANAWHA COUNTY SCHOOLS")

# Filter to demographic subgroup
hispanic <- enr_2025 |>
  dplyr::filter(subgroup == "hispanic", is_state)
} # }