Installation
Install from GitHub:
# install.packages("devtools")
devtools::install_github("almartin82/tnschooldata")Quick Start
Fetch enrollment data
The main function is fetch_enr(). It downloads
enrollment data from the Tennessee Department of Education for a given
school year.
Data structure
The default output is in “tidy” (long) format with these key columns:
-
end_year: School year end (e.g., 2024 for 2023-24) -
type: “State”, “District”, or “Campus” -
district_id: 4-digit district ID -
campus_id: 8-digit campus ID (district + school) -
district_name,campus_name: Names -
grade_level: “TOTAL”, “K”, “01”-“12”, or aggregates like “K8”, “HS” -
subgroup: “total_enrollment”, “white”, “black”, “hispanic”, etc. -
n_students: Student count -
pct: Percentage of total enrollment -
is_state,is_district,is_campus: Boolean flags
Multiple years
Use fetch_enr_multi() to get data for multiple
years:
enr_multi <- fetch_enr_multi(2019:2024)
# Track state enrollment over time
enr_multi %>%
filter(is_state, subgroup == "total_enrollment", grade_level == "TOTAL") %>%
select(end_year, n_students)Wide format
Use tidy = FALSE for wide format with one row per
entity:
Wide format includes columns like: - row_total: Total
enrollment - white, black,
hispanic, asian: Demographic counts -
grade_k, grade_01, …, grade_12:
Grade-level enrollment - econ_disadv, lep,
special_ed: Special population counts
Available Years
Tennessee enrollment data is available from 1999-2024:
- 1999-2011: Historical data from Annual Statistical Reports (district-level only)
- 2012-2024: Modern data from TDOE portal (includes school-level)
Caching
Data is automatically cached locally to speed up repeated requests:
# View cache status
cache_status()
# Force fresh download
enr_fresh <- fetch_enr(2024, use_cache = FALSE)
# Clear cache
clear_cache(2024, "tidy")