Skip to contents

Downloads and processes school directory data from the Montana Office of Public Instruction (OPI) Reporting Center. This includes all public schools and districts with contact information and administrator names.

Usage

fetch_directory(end_year = NULL, tidy = TRUE, use_cache = TRUE)

Arguments

end_year

School year end (e.g., 2024 for 2023-24). If NULL (default), fetches the current directory which represents the most recent data.

tidy

If TRUE (default), returns data in a standardized format with consistent column names. If FALSE, returns raw column names from OPI.

use_cache

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

Value

A tibble with school directory data. Columns include:

  • school_id: OPI school identifier

  • school_name: School name

  • district_name: District/system name

  • school_type: Type of school (e.g., "Elementary", "High School")

  • grades_served: Grade levels served

  • address: Street address

  • city: City

  • state: State (always "MT")

  • zip: ZIP code

  • phone: Phone number

  • principal_name: Principal name (for schools)

  • superintendent_name: Superintendent name (for districts)

  • county: County name

Details

The directory data is retrieved from Montana OPI's Reporting Center. This data represents the current state of Montana schools and districts and is updated periodically by OPI.

Montana OPI organizes schools within "Systems" which are groups of one or more districts that share a central office.

Examples

if (FALSE) { # \dontrun{
# Get school directory data
dir_data <- fetch_directory()

# Get raw format (original OPI column names)
dir_raw <- fetch_directory(tidy = FALSE)

# Force fresh download (ignore cache)
dir_fresh <- fetch_directory(use_cache = FALSE)

# Filter to high schools only
library(dplyr)
high_schools <- dir_data |>
  filter(grepl("High School", school_type))
} # }