names(deidentify::initiations)
#>  [1] "case_id"                             
#>  [2] "case_participant_id"                 
#>  [3] "received_date"                       
#>  [4] "offense_category"                    
#>  [5] "primary_charge_flag"                 
#>  [6] "charge_id"                           
#>  [7] "charge_version_id"                   
#>  [8] "charge_offense_title"                
#>  [9] "charge_count"                        
#> [10] "chapter"                             
#> [11] "act"                                 
#> [12] "section"                             
#> [13] "class"                               
#> [14] "aoic"                                
#> [15] "event"                               
#> [16] "event_date"                          
#> [17] "finding_no_probable_cause"           
#> [18] "arraignment_date"                    
#> [19] "bond_date_initial"                   
#> [20] "bond_date_current"                   
#> [21] "bond_type_initial"                   
#> [22] "bond_type_current"                   
#> [23] "bond_amount_initial"                 
#> [24] "bond_amount_current"                 
#> [25] "bond_electronic_monitor_flag_initial"
#> [26] "bond_electronic_monitor_flag_current"
#> [27] "age_at_incident"                     
#> [28] "race"                                
#> [29] "gender"                              
#> [30] "incident_city"                       
#> [31] "incident_begin_date"                 
#> [32] "incident_end_date"                   
#> [33] "law_enforcement_agency"              
#> [34] "law_enforcement_unit"                
#> [35] "arrest_date"                         
#> [36] "felony_review_date"                  
#> [37] "felony_review_result"                
#> [38] "updated_offense_category"
head(data.frame(deidentify::initiations))
#>        case_id case_participant_id received_date             offense_category
#> 1 773232058636        512565032738    2016-01-27            Credit Card Cases
#> 2 784453927394        524833143957    2017-06-15 UUW - Unlawful Use of Weapon
#> 3 718200412833        455806284733    2011-12-21                Other Offense
#> 4 787824305996        528496953356    2017-10-07                   Sex Crimes
#> 5 801791055279        543196827744    2019-01-28           Aggravated Battery
#> 6 796776781079        538078435902    2018-08-14 UUW - Unlawful Use of Weapon
#>   primary_charge_flag    charge_id charge_version_id
#> 1               FALSE 400511128519      458078354422
#> 2               FALSE 412970779201      472619121554
#> 3               FALSE 351586253842      401382841906
#> 4                TRUE 415478118967      475566492675
#> 5               FALSE 432243616209      495207783862
#> 6               FALSE 425221684897      486969730193
#>                                charge_offense_title charge_count chapter act
#> 1                      CONTINUING FIN CRIME ENTRPRS            2     720   5
#> 2 UNLAWFUL USE OR POSSESSION OF A WEAPON BY A FELON            2     720   5
#> 3                     AGG RECKLESS DRVG/BODILY HARM            2     625   5
#> 4                  AGGRAVATED CRIMINAL SEXUAL ABUSE            1     720   5
#> 5                                AGGRAVATED BATTERY            5     720   5
#> 6                 AGGRAVATED UNLAWFUL USE OF WEAPON           13     720   5
#>         section class    aoic               event event_date
#> 1    17-10.6(h)     1 0016193 Preliminary Hearing 2016-06-08
#> 2     24-1.1(a)     3 1214500          Indictment 2017-07-14
#> 3  11-503(a)(1)     4 0013565 Preliminary Hearing 2012-01-19
#> 4    11-1.60(b)     2 0015825          Indictment 2017-11-01
#> 5 12-3.05(d)(5)     3 0016109 Preliminary Hearing 2019-05-10
#> 6  24-1.6(a)(1)     2 0012476          Indictment 2018-09-07
#>   finding_no_probable_cause arraignment_date bond_date_initial
#> 1                      <NA>             <NA>        2016-01-28
#> 2                      <NA>       2017-07-28              <NA>
#> 3                      <NA>       2012-02-17        2011-12-27
#> 4                      <NA>       2017-11-07        2017-10-09
#> 5                      <NA>       2019-06-05        2019-01-28
#> 6                      <NA>       2018-09-25        2018-08-15
#>   bond_date_current bond_type_initial bond_type_current bond_amount_initial
#> 1        2016-01-28            D Bond            D Bond               20000
#> 2              <NA>              <NA>              <NA>                  NA
#> 3        2011-12-27            D Bond            D Bond               30000
#> 4        2017-10-09            D Bond            D Bond               50000
#> 5        2019-01-28            D Bond            D Bond               10000
#> 6        2018-08-15           No Bond           No Bond                  NA
#>   bond_amount_current bond_electronic_monitor_flag_initial
#> 1               20000                                   NA
#> 2                  NA                                   NA
#> 3               30000                                   NA
#> 4               50000                                   NA
#> 5               10000                                   NA
#> 6                  NA                                   NA
#>   bond_electronic_monitor_flag_current age_at_incident
#> 1                                   NA              21
#> 2                                   NA              55
#> 3                                   NA              18
#> 4                                   NA              31
#> 5                                   NA              26
#> 6                                   NA              31
#>                         race gender  incident_city incident_begin_date
#> 1                      Black   Male       Matteson          2015-12-15
#> 2                      White   Male        Chicago          2017-06-14
#> 3                      White   Male Mount Prospect          2011-12-20
#> 4 White [Hispanic Or Latino]   Male       Wheeling          2017-10-05
#> 5                      White   Male        Chicago          2019-01-27
#> 6                      White   Male Evergreen Park          2018-08-13
#>   incident_end_date law_enforcement_agency law_enforcement_unit
#> 1              <NA>         PARK FOREST PD                 <NA>
#> 2              <NA>             CHICAGO PD District 9 - Deering
#> 3              <NA>      MOUNT PROSPECT PD                 <NA>
#> 4        2017-10-07            WHEELING PD                 <NA>
#> 5              <NA>             CHICAGO PD                 <NA>
#> 6              <NA>      EVERGREEN PARK PD                 <NA>
#>           arrest_date felony_review_date felony_review_result
#> 1 2016-01-25 14:45:00         2016-05-17             Approved
#> 2 2017-06-15 10:17:00         2017-06-15             Approved
#> 3 2011-12-20 02:36:00         2011-12-26             Approved
#> 4 2017-10-06 17:46:00         2017-10-08             Approved
#> 5 2019-01-27 21:12:00         2019-01-28             Approved
#> 6 2018-08-14 16:00:00         2018-08-14             Approved
#>       updated_offense_category
#> 1         Residential Burglary
#> 2 UUW - Unlawful Use of Weapon
#> 3           Aggravated Battery
#> 4                   Sex Crimes
#> 5           Aggravated Battery
#> 6 UUW - Unlawful Use of Weapon
temp <- make_k_score(deidentify::initiations, columns = c("race"))
#> Note: There are 1 groups with 3 or fewer observations.
temp
#>                               race number_of_observations
#> 1                          Unknown                      1
#> 2                            Asian                      8
#> 3                             <NA>                      9
#> 4 White/Black [Hispanic Or Latino]                     21
#> 5                            White                    120
#> 6       White [Hispanic Or Latino]                    164
#> 7                            Black                    677
summary(temp$number_of_observations)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>     1.0     8.5    21.0   142.9   142.0   677.0
temp <- make_k_score(deidentify::initiations, columns = c("race", "gender"))
#> Note: There are 4 groups with 3 or fewer observations.
temp
#>                                race gender number_of_observations
#> 1                           Unknown   Male                      1
#> 2                             White   <NA>                      1
#> 3                              <NA> Female                      1
#> 4                             Asian Female                      2
#> 5                             Asian   Male                      6
#> 6                              <NA>   <NA>                      8
#> 7        White [Hispanic Or Latino] Female                     10
#> 8                             White Female                     17
#> 9  White/Black [Hispanic Or Latino]   Male                     21
#> 10                            Black Female                     62
#> 11                            White   Male                    102
#> 12       White [Hispanic Or Latino]   Male                    154
#> 13                            Black   Male                    615
summary(temp$number_of_observations)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>    1.00    2.00   10.00   76.92   62.00  615.00
temp <- make_k_score(deidentify::initiations, columns = c("race", "gender", "offense_category"))
#> Note: There are 115 groups with 3 or fewer observations.
nrow(temp)
#> [1] 168
head(temp)
#>    race gender                          offense_category number_of_observations
#> 1 Asian Female                             Other Offense                      1
#> 2 Asian Female                                     Theft                      1
#> 3 Asian   Male Driving With Suspended Or Revoked License                      1
#> 4 Asian   Male                                     Fraud                      1
#> 5 Asian   Male                                     Theft                      1
#> 6 Asian   Male              UUW - Unlawful Use of Weapon                      1
tail(temp)
#>                           race gender                          offense_category
#> 163 White [Hispanic Or Latino]   Male              UUW - Unlawful Use of Weapon
#> 164 White [Hispanic Or Latino]   Male                            Aggravated DUI
#> 165                      Black   Male Driving With Suspended Or Revoked License
#> 166                      Black   Male                                  Homicide
#> 167                      Black   Male                                 Narcotics
#> 168                      Black   Male              UUW - Unlawful Use of Weapon
#>     number_of_observations
#> 163                     24
#> 164                     25
#> 165                     26
#> 166                     37
#> 167                    129
#> 168                    162
summary(temp$number_of_observations)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   1.000   1.000   2.000   5.952   5.000 162.000