This function forces values the variables in .var to take constant values within combinations of the variables in .within. fixed_force() will return a data frame with consistency enforced.
fixed_force( .df, .var = NULL, .within = NULL, .resolve = mode_order, .flag = NA )
| .df | Data frame, pibble, or tibble. | 
|---|---|
| .var | Quoted or unquoted variable(s) in  | 
| .within | Quotes or unquoted variable(s) that the  | 
| .resolve | Function capable of being passed to  | 
| .flag | String indicating the name of a new variable that flags any observations altered by  | 
Inconsistencies will be resolved by the function .resolve. Or, set .resolve to 'drop' (or any string, really) to drop all cases with inconsistency.
data(Scorecard) # The variables pred_degree_awarded_ipeds and state_abbr should be constant within unitid # However, sometimes colleges change what they offer. # For the purpose of my analysis, though, # I want to treat any changers as whatever they are most often (the mode). # So let's enforce that with fixed_force Scorecard <- fixed_force(Scorecard, .var = c(pred_degree_awarded_ipeds, state_abbr), .within = unitid, .flag = "changed" ) # Did we catch any changers? table(Scorecard$changed)#> #> FALSE TRUE #> 48392 53# We did!