Red-flag scan: where a district sits in the top or bottom decile of peers
Source:R/tges_analysis.R
tges_red_flags.RdThe product a board member actually wants before a meeting. Runs
tges_percentile_rank() across every major spending indicator for one
district and surfaces the ones where it lands in the top or bottom decile of
its peer group. The output is a one-page "you are top-decile in legal services
and plant O&M, bottom-decile in classroom share" brief.
Usage
tges_red_flags(
tges,
district_id,
peer = c("tges_group", "dfg", "county", "statewide"),
year = NULL,
calc_type = "Budgeted",
threshold = 10,
only_flagged = TRUE,
dfg_revision = 2000
)Arguments
- tges
Output of
fetch_tges()(a single guide) orfetch_many_tges().- district_id
Character. The 4-digit focal district code (Newark = "3570").
- peer
Character. Peer group. See
tges_percentile_rank(). Default"tges_group".- year
Numeric. Report year to scan. Default: the latest
end_yearpresent.- calc_type
Character. For the per-pupil cost tables, which calc type to rank. Default
"Budgeted"(the current-year budgeted figure).- threshold
Numeric. Decile width in percentile points. Default 10: percentile
<= 10is bottom-decile,>= 90is top-decile.- only_flagged
Logical. If
TRUE(default) return only the top/bottom-decile rows; ifFALSEreturn the full indicator profile with aflagcolumn (NAwhen not extreme).- dfg_revision
Numeric. DFG revision when
peer = "dfg". Default 2000.
Details
The scan covers the per-pupil cost tables (CSG1, CSG2, CSG6, CSG8,
CSG8A, CSG10, CSG12, CSG13, CSG15) ranked on "Per Pupil costs", plus the
classroom and administration shares from tges_composition(). Each row
carries higher_means so the direction is unambiguous: a top-decile
"Administration $/pupil" is a cost flag, while a top-decile "Classroom share"
is favourable. Percentile is recomputed within the chosen peer group (not NJ's
published enrollment-band rank, unless peer = "tges_group"), so all
indicators use one consistent peer system.
Examples
if (FALSE) { # \dontrun{
library(dplyr)
# Newark's red flags within its enrollment-band peers
tges_red_flags(fetch_tges(2024), district_id = "3570")
# Full profile within DFG A peers, nothing hidden
tges_red_flags(fetch_tges(2024), district_id = "3570",
peer = "dfg", only_flagged = FALSE)
} # }