Creates grouping on a dataframe that defines which entities
are compared to each other for percentile rank calculations. The returned
df can be piped directly to percentile_rank().
Arguments
- df
Dataframe with entity identifiers
- peer_type
Character. One of:
"statewide": Compare to all districts/schools in state
"dfg": Compare within District Factor Group
"county": Compare within county
"custom": Compare to custom list of district_ids
- custom_ids
Character vector of district_ids for custom peer groups. Only used when peer_type = "custom".
- level
Character. One of "district" or "school" - what level to compare.
- year_col
Character. Name of the year column. Default "end_year".
- additional_groups
Character vector. Additional columns to group by (e.g., "subgroup", "grade", "test_name").
Value
Grouped dataframe ready for add_percentile_rank()
Examples
if (FALSE) { # \dontrun{
# DFG peer group for districts
grate %>%
define_peer_group("dfg", level = "district") %>%
add_percentile_rank("grad_rate")
# Custom peer group (DFG A districts)
grate %>%
define_peer_group("custom", custom_ids = dfg_a_districts, level = "district") %>%
add_percentile_rank("grad_rate")
} # }