├── .Rbuildignore ├── .gitignore ├── .here ├── DESCRIPTION ├── FBI Data.xlsx ├── FBI Uniform Crime Reporting (UCR) Program User Manual.pdf ├── NAMESPACE ├── NEWS.md ├── R ├── SHR.R ├── arrests.R ├── arson.R ├── crosswalk.R ├── hate_crimes.R ├── human_trafficking.R ├── leoka.R ├── make_sps │ ├── make_arrest_post_2020_sps.R │ ├── make_arrest_sps.R │ ├── make_arson_sps.R │ ├── make_hate_crime_batch_header_sps.R │ ├── make_hate_crime_incident_report_sps.R │ ├── make_human_trafficking_sps.R │ ├── make_leoka_sps.R │ ├── make_nibrs_batch_header_1_sps.R │ ├── make_nibrs_batch_header_2_sps.R │ ├── make_nibrs_batch_header_3_sps.R │ ├── make_offenses_known_sps.R │ ├── make_shr_sps.R │ ├── make_sps_utils.R │ ├── make_supplement_sps.R │ ├── nibrs_administrative_segment_sps.R │ ├── nibrs_arrestee_segment_sps.R │ ├── nibrs_group_b_arrest_report_segment_sps.R │ ├── nibrs_offender_segment_sps.R │ ├── nibrs_offense_segment_sps.R │ ├── nibrs_property_segment_sps.R │ ├── nibrs_sps_utils.R │ ├── nibrs_victim_segment_sps.R │ ├── nibrs_window_arrestee_segment_sps.R │ ├── nibrs_window_exceptional_clearance_segment_sps.R │ └── nibrs_window_recovered_property_segment_sps.R ├── nibrs.R ├── nibrs_batch_header.R ├── offenses_known.R ├── parse_raw_nibrs_master_files.R ├── supplement_return_a.R ├── utils-pipe.R └── utils │ ├── SHR_utils.R │ ├── arrests_utils.R │ ├── arrests_utils_objects.R │ ├── global_utils.R │ ├── hate_crime_utils.R │ ├── leoka_utils.R │ ├── offenses_known_utils.R │ ├── saving_utils.R │ └── supplement_utils.R ├── README.md ├── compress_stata_files.do ├── crime_data.Rproj ├── crosswalk.rds ├── fatal-police-shootings-data.csv ├── fbi_record_descriptions ├── ASR Records Description updated summarized.xlsx ├── Arson Record Description.pdf ├── Arson Records Description updated.xlsx ├── Cargo Theft Technical Specification1.docx ├── HCrecorddescrip.pdf ├── Hate Crime Technical Specification v.1.2 6-29-18.docx ├── NIBRS Record Description.pdf ├── NIBRS Records Description updated.xlsx ├── Police Employee - LEOKA Records Description updated.xlsx ├── Police Employee Record Description.pdf ├── Record Description.pdf ├── Return A Record Description.pdf ├── Return A Records Description updated.xlsx ├── SHRYR current Record Layout.pdf ├── Summary Reporting Technical Specification.docx ├── Supplement to Return A Records Description updated.xlsx ├── Supplementary Homicide Report Records Description updated.xlsx ├── asr_month_1974_1979.pdf ├── asr_month_1980_present.pdf ├── cargo_theft.docx ├── human-trafficking-help.docx ├── retarecdesc.wpd ├── supprecdes.wpd └── supprecdes.wpd.pdf ├── final_washpost_ucr_merged.dta ├── inst └── testdata │ ├── alexander_alabama.csv │ ├── birmingham_alabama.csv │ ├── fairfield_alabama.csv │ ├── fort_payne_alabama.csv │ ├── huntsville_alabama.csv │ ├── madison_alabama.csv │ ├── mobile_alabama.csv │ ├── oxford_alabama.csv │ ├── ozark_alabama.csv │ └── tuscaloosa_alabama.csv ├── pa_ucr_crosswalk.csv ├── setup_files ├── arrests_agency_header_1974_1979.sps ├── arrests_agency_header_1980_present.sps ├── arrests_agency_header_post_2020.sps ├── arrests_detail_header_1974_1979.sps ├── arrests_detail_header_1980_present.sps ├── arrests_detail_header_post_2020.sps ├── arrests_monthly_header_1974_1979.sps ├── arrests_monthly_header_1980_present.sps ├── crime_data_crosswalk.dta ├── human_trafficking.sps ├── nibrs_administrative_segment.sps ├── nibrs_arrestee_segment.sps ├── nibrs_batch_header_1.sps ├── nibrs_batch_header_2.sps ├── nibrs_batch_header_3.sps ├── nibrs_group_b_arrest_report_segment.sps ├── nibrs_offender_segment.sps ├── nibrs_offense_segment.sps ├── nibrs_property_segment.sps ├── nibrs_victim_segment.sps ├── nibrs_window_arrestee_segment.sps ├── nibrs_window_exceptional_clearance_segment.sps ├── nibrs_window_recovered_property_segment.sps ├── shr_1976_2021_dta.zip ├── supplement_to_return_a.sps ├── ucr_arson.sps ├── ucr_hate_crimes_batch_header.sps ├── ucr_hate_crimes_incident_report.sps ├── ucr_leoka.sps ├── ucr_return_a.sps └── ucr_shr.sps └── tests ├── testthat.R └── testthat └── test-offenses_known_values.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | raw_data/ 6 | clean_data/ -------------------------------------------------------------------------------- /.here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/.here -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: crimedata 2 | Title: Clean FBI data 3 | Version: 1.0.0 4 | Authors@R: person("Jacob", "Kaplan", email = "jkkaplan6@gmail.com", role = c("aut", "cre")) 5 | Description: Cleans and prepares FBI data for public use. 6 | Imports: 7 | dplyr, 8 | asciiSetupReader, 9 | stringr, 10 | readr, 11 | rmarkdown, 12 | data.table, 13 | magrittr, 14 | memisc, 15 | haven 16 | License: GPL 17 | Encoding: UTF-8 18 | LazyData: true 19 | RoxygenNote: 6.0.1 20 | Suggests: 21 | testthat 22 | VignetteBuilder: knitr 23 | -------------------------------------------------------------------------------- /FBI Data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/FBI Data.xlsx -------------------------------------------------------------------------------- /FBI Uniform Crime Reporting (UCR) Program User Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/FBI Uniform Crime Reporting (UCR) Program User Manual.pdf -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("%>%") 4 | importFrom(magrittr,"%>%") 5 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # crimedata 1.0.0 2 | 3 | * Added a `NEWS.md` file to track changes to the package. 4 | -------------------------------------------------------------------------------- /R/arson.R: -------------------------------------------------------------------------------- 1 | library(here) 2 | source(here('R/utils/global_utils.R')) 3 | source(here('R/make_sps/make_arson_sps.R')) 4 | source(here('R/crosswalk.R')) 5 | crosswalk <- read_merge_crosswalks() 6 | 7 | get_arson_monthly(crosswalk) 8 | arson_yearly <- get_data_yearly("arson", "1979_2021", "ucr_arson_yearly_", crosswalk) 9 | names(arson_yearly) 10 | table(arson_yearly$year) 11 | table(arson_yearly$number_of_months_missing) 12 | 13 | table(arson_yearly$last_month_reported[arson_yearly$year %in% 2019]) 14 | table(arson_yearly$last_month_reported[arson_yearly$year %in% 2020]) 15 | 16 | 17 | summary(arson_yearly$est_damage_storage[arson_yearly$year %in% 2019]) 18 | summary(arson_yearly$est_damage_storage[arson_yearly$year %in% 2021]) 19 | summary(arson_yearly$cleared_18_grand_total[arson_yearly$year %in% 2019]) 20 | summary(arson_yearly$cleared_18_grand_total[arson_yearly$year %in% 2021]) 21 | summary(arson_yearly$actual_all_other[arson_yearly$year %in% 2019]) 22 | summary(arson_yearly$actual_all_other[arson_yearly$year %in% 2021]) 23 | 24 | 25 | summary(arson_yearly[arson_yearly$year %in% 2021, ]) 26 | 27 | global_checks(arson_yearly) 28 | setwd(here("E:/ucr_data_storage/clean_data/arson")) 29 | save_as_zip("ucr_arson_monthly_1979_2021_", pattern = "month") 30 | save_as_zip("ucr_arson_yearly_1979_2021_", pattern = "year") 31 | 32 | get_arson_monthly <- function(crosswalk) { 33 | setwd(here("D:/ucr_data_storage/raw_data/arson_from_fbi")) 34 | files <- list.files() 35 | files <- files[grepl(".txt|.dat", files, ignore.case = TRUE)] 36 | print(files) 37 | for (file in files) { 38 | setwd(here("D:/ucr_data_storage/raw_data/arson_from_fbi")) 39 | message(file) 40 | data <- read_ascii_setup(file, here("setup_files/ucr_arson.sps")) 41 | 42 | data <- 43 | data %>% 44 | # ORI NY03200 has multiple years that reported single arsons 45 | # costing over $700 million 46 | filter(ori != "NY03200", 47 | !is.na(ori)) %>% 48 | mutate_if(is.character, tolower) %>% 49 | mutate(state_abb = make_state_abb(state), 50 | ori = toupper(ori), 51 | year = fix_years(year)) %>% 52 | select(-matches("date_of|month_included"), 53 | -state_name, 54 | -identifier_code, 55 | -covered_by_group, 56 | -county, 57 | -msa, 58 | -sequence_number, 59 | -core_city_indicator) %>% 60 | # for some reason in 2019 there are a bunch of agencies with duplicate 61 | # rows 62 | distinct(ori, .keep_all = TRUE) 63 | data <- fix_all_negatives(data) 64 | data <- month_wide_to_long(data) 65 | 66 | # Calculates the number of months missing based on the sum of months 67 | # which did not submit data (based on the column_2_type variable. Column 2 68 | # is for actual offenses) 69 | data <- fix_number_of_months_reported(data, type = "arson") 70 | data <- get_months_missing_annual(data) 71 | data <- 72 | data %>% 73 | select(-number_of_months_reported, 74 | -starts_with("column")) 75 | 76 | data <- left_join(data, crosswalk, by = "ori") 77 | data <- reorder_columns(data, crosswalk, type = "month") 78 | 79 | data$population_group[data$population_group %in% "7b"] <- NA 80 | # Very incorrect mobile arson data 81 | if (data$year[1] == 2016) { 82 | data <- 83 | data %>% 84 | filter(ori != "GA06059") 85 | } 86 | if (data$year[1] == 1989) { 87 | data$uninhabited_single_occupancy[data$ori %in% "NC09000" & 88 | data$month %in% "january"] <- NA 89 | data$uninhabited_total_structures[data$ori %in% "NC09000" & 90 | data$month %in% "january"] <- NA 91 | data$uninhabited_grand_total[data$ori %in% "NC09000" & 92 | data$month %in% "january"] <- NA 93 | } 94 | if (data$year[1] == 1991) { 95 | data$est_damage_community_public[data$ori %in% "FL02000" & 96 | data$month %in% "december"] <- NA 97 | data$est_damage_total_structures[data$ori %in% "FL02000" & 98 | data$month %in% "december"] <- NA 99 | data$est_damage_grand_total[data$ori %in% "FL02000" & 100 | data$month %in% "december"] <- NA 101 | } 102 | if (data$year[1] == 2017) { 103 | data$uninhabited_storage[data$ori %in% "MN06209" & 104 | data$month %in% "april"] <- NA 105 | data$uninhabited_community_public[data$ori %in% "MN06209" & 106 | data$month %in% "april"] <- NA 107 | data$uninhabited_total_structures[data$ori %in% "MN06209" & 108 | data$month %in% "april"] <- NA 109 | data$uninhabited_grand_total[data$ori %in% "MN06209" & 110 | data$month %in% "april"] <- NA 111 | } 112 | 113 | data$state[data$state %in% c("69", "98", "99")] <- NA 114 | 115 | # Save the data in various formats 116 | setwd(here("D:/ucr_data_storage/clean_data/arson")) 117 | save_files(data = data, 118 | year = data$year[1], 119 | file_name = "ucr_arson_monthly_", 120 | save_name = "ucr_arson_monthly_") 121 | rm(data); gc(); #Sys.sleep(3) 122 | } 123 | } 124 | 125 | 126 | -------------------------------------------------------------------------------- /R/human_trafficking.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/crosswalk.R')) 2 | source(here::here('R/utils/global_utils.R')) 3 | source(here::here('R/make_sps/make_human_trafficking_sps.R')) 4 | crosswalk <- read_merge_crosswalks() 5 | 6 | human_trafficking_monthly <- get_human_trafficking_monthly() 7 | human_trafficking_yearly <- get_data_yearly("human_trafficking", 8 | "2013_2019", 9 | "human_trafficking_yearly_", 10 | crosswalk) 11 | table(human_trafficking_yearly$year) 12 | table(human_trafficking_yearly$number_of_months_reported) 13 | 14 | table(human_trafficking_yearly$number_of_months_reported[human_trafficking_yearly$year %in% 2018]) 15 | table(human_trafficking_yearly$number_of_months_reported[human_trafficking_yearly$year %in% 2019]) 16 | 17 | 18 | summary(human_trafficking_yearly$actual_commercial_sex_acts[human_trafficking_yearly$year %in% 2018]) 19 | summary(human_trafficking_yearly$actual_commercial_sex_acts[human_trafficking_yearly$year %in% 2019]) 20 | summary(human_trafficking_yearly$reported_involuntary_serv[human_trafficking_yearly$year %in% 2018]) 21 | summary(human_trafficking_yearly$reported_involuntary_serv[human_trafficking_yearly$year %in% 2019]) 22 | summary(human_trafficking_yearly$tot_clr_total[human_trafficking_yearly$year %in% 2018]) 23 | summary(human_trafficking_yearly$tot_clr_total[human_trafficking_yearly$year %in% 2019]) 24 | 25 | summary(human_trafficking_monthly$actual_commercial_sex_acts[human_trafficking_monthly$year %in% 2018]) 26 | summary(human_trafficking_monthly$actual_commercial_sex_acts[human_trafficking_monthly$year %in% 2019]) 27 | summary(human_trafficking_monthly$reported_involuntary_serv[human_trafficking_monthly$year %in% 2018]) 28 | summary(human_trafficking_monthly$reported_involuntary_serv[human_trafficking_monthly$year %in% 2019]) 29 | summary(human_trafficking_monthly$tot_clr_total[human_trafficking_monthly$year %in% 2018]) 30 | summary(human_trafficking_monthly$tot_clr_total[human_trafficking_monthly$year %in% 2019]) 31 | 32 | summary(human_trafficking_monthly) 33 | summary(human_trafficking_yearly) 34 | 35 | table(human_trafficking_monthly$state) 36 | table(human_trafficking_monthly$population_group) 37 | table(human_trafficking_monthly$country_division ) 38 | 39 | 40 | setwd(here::here("clean_data/human_trafficking")) 41 | save_as_zip("human_trafficking_2013_2019_") 42 | 43 | get_human_trafficking_monthly <- function() { 44 | setwd(here::here("raw_data/human_trafficking")) 45 | files <- list.files() 46 | final <- data.frame() 47 | for (file in files) { 48 | data <- read_ascii_setup(file, here::here("setup_files/human_trafficking.sps")) %>% 49 | mutate_if(is.character, tolower) %>% 50 | mutate(year = fix_years(year), 51 | ori = toupper(ori), 52 | state_abb = make_state_abb(state), 53 | covered_by_ori = as.character(covered_by_ori), 54 | covered_by_ori = toupper(covered_by_ori)) %>% 55 | select(-agency_state_name, 56 | -identifier_code, 57 | -sequence_number, 58 | -number_of_months_reported, 59 | -covered_by_population_group) %>% 60 | mutate_at(vars(tidyselect::ends_with("report_code")), str_replace_all, 61 | months_reported_fix) %>% 62 | mutate_at(vars(tidyselect::ends_with("report_code")), as.numeric) %>% 63 | mutate(number_of_months_reported = select(., 64 | contains("report_code")) %>% rowSums()) %>% 65 | mutate_at(vars(tidyselect::matches("reported|unfound|actual|clr|tot")), 66 | replace_na, 0) 67 | 68 | data$state[data$state %in% c("69", "98", "99")] <- NA 69 | data <- month_wide_to_long(data) 70 | names(data) <- gsub("report_code", "month_reported_indicator", 71 | names(data)) 72 | 73 | 74 | final <- bind_rows(final, data) 75 | 76 | } 77 | 78 | final <- left_join(final, crosswalk, by = "ori") 79 | final <- reorder_columns(final, crosswalk) 80 | final <- 81 | final %>% 82 | arrange(ori, 83 | desc(date)) 84 | 85 | setwd(here::here("clean_data/human_trafficking")) 86 | save_files(data = final, 87 | year = paste0(min(final$year), "_", max(final$year)), 88 | file_name = "human_trafficking_monthly_", 89 | save_name = "human_trafficking_monthly_", 90 | rda_and_stata_only = FALSE) 91 | 92 | return(final) 93 | } 94 | 95 | months_reported_fix <- c("data received" = "1", 96 | "no human trafficking information reported" = "0", 97 | "type 14, no report" = "0") 98 | -------------------------------------------------------------------------------- /R/leoka.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/crosswalk.R')) 2 | source(here::here('R/make_sps/make_leoka_sps.R')) 3 | source(here::here('R/utils/global_utils.R')) 4 | crosswalk <- read_merge_crosswalks() 5 | #saveRDS(crosswalk, file = here::here("crosswalk.rds")) 6 | source(here::here('R/utils/leoka_utils.R')) 7 | 8 | get_all_leoka_monthly() 9 | leoka_yearly <- get_all_leoka_yearly() 10 | global_checks(leoka_yearly) 11 | sapply(leoka_yearly, function(x) max(x, na.rm = TRUE)) 12 | 13 | summary(leoka_yearly$one_man_veh_day_shift[leoka_yearly$year %in% 2017]) 14 | summary(leoka_yearly$one_man_veh_day_shift[leoka_yearly$year %in% 2021]) 15 | summary(leoka_yearly$traffic_assaults_cleared[leoka_yearly$year %in% 2019]) 16 | summary(leoka_yearly$traffic_assaults_cleared[leoka_yearly$year %in% 2021]) 17 | summary(leoka_yearly$male_employees_officers[leoka_yearly$year %in% 2019]) 18 | summary(leoka_yearly$male_employees_officers[leoka_yearly$year %in% 2021]) 19 | summary(leoka_yearly$female_employees_officers[leoka_yearly$year %in% 2019]) 20 | summary(leoka_yearly$female_employees_officers[leoka_yearly$year %in% 2021]) 21 | 22 | summary(leoka_yearly$officers_killed_total[leoka_yearly$year %in% 2019]) 23 | summary(leoka_yearly$officers_killed_total[leoka_yearly$year %in% 2021]) 24 | summary(leoka_yearly$assaults_no_injury_total[leoka_yearly$year %in% 2019]) 25 | summary(leoka_yearly$assaults_no_injury_total[leoka_yearly$year %in% 2021]) 26 | 27 | table(leoka_yearly$year, leoka_yearly$number_of_months_reported) 28 | 29 | setwd(here::here("E:/ucr_data_storage/clean_data/LEOKA")) 30 | save_as_zip("ucr_leoka_monthly_1960_2021_", pattern = "month") 31 | save_as_zip("ucr_leoka_yearly_1960_2021_", pattern = "year") 32 | 33 | get_all_leoka_monthly <- function() { 34 | setwd(here::here("D:/ucr_data_storage/raw_data/leoka_from_fbi")) 35 | files <- list.files() 36 | files <- files[!grepl("sps", files)] 37 | print(files) 38 | for (file in files) { 39 | setwd(here::here("D:/ucr_data_storage/raw_data/leoka_from_fbi")) 40 | data <- asciiSetupReader::spss_ascii_reader(file, 41 | here::here("setup_files/ucr_leoka.sps")) %>% 42 | filter(!ori %in% "0000000") 43 | data <- make_number_of_months_reporting(data) 44 | 45 | data <- 46 | data %>% 47 | dplyr::filter(!is.na(ori)) %>% 48 | dplyr::select(-officer_rate_per_1000_pop, 49 | -employee_rate_per_1000_pop, 50 | -identifier_code, 51 | -month_included, 52 | -state_name, 53 | -sequence_number, 54 | -contains("blank")) %>% 55 | dplyr::mutate_at(vars(contains("injury_indicator")), remove_special_characters) %>% 56 | dplyr::mutate_if(is.character, tolower) %>% 57 | dplyr::mutate(year = fix_years(year), 58 | ori = toupper(ori), 59 | total_employees_officers = rowSums(.[, grepl("male_employees_officers", 60 | names(.))]), 61 | total_employees_civilians = rowSums(.[, grepl("male_employees_civilians", 62 | names(.))]), 63 | covered_by = as.character(covered_by), 64 | shift_data = as.character(shift_data), 65 | no_male_female_breakdown = as.character(no_male_female_breakdown), 66 | state_abb = make_state_abb(state)) %>% 67 | dplyr::rename(total_employees_total = total_employees) 68 | 69 | data <- fix_all_negatives(data) 70 | data$population[data$population > 200000000] <- NA 71 | 72 | data <- fix_outliers(data) 73 | data <- month_wide_to_long(data) 74 | data <- dplyr::left_join(data, crosswalk, by = "ori") 75 | data$officers_killed_total <- data$officers_killed_by_felony + 76 | data$officers_killed_by_accident 77 | data <- reorder_leoka_columns(data, crosswalk) 78 | 79 | data$state[data$state %in% c("69", "98", "99")] <- NA 80 | data$population_group[data$population_group %in% c("2c", "7b")] <- NA 81 | 82 | # Save the data in various formats 83 | setwd(here::here("D:/ucr_data_storage/clean_data/LEOKA")) 84 | save_files(data = data, 85 | year = data$year[1], 86 | file_name = "leoka_monthly_", 87 | save_name = "leoka_monthly_") 88 | message(unique(data$year)) 89 | rm(data); gc(); Sys.sleep(3) 90 | } 91 | } 92 | 93 | 94 | get_all_leoka_yearly <- function() { 95 | setwd(here::here("D:/ucr_data_storage/clean_data/LEOKA")) 96 | files <- list.files(pattern = "monthly_.*.rds$") 97 | print(files) 98 | leoka_yearly <- data.frame() 99 | for (file in files) { 100 | data <- readRDS(file) 101 | 102 | month_cols <- grep("assault|ambush|disturbance|all_oth|arrest|traffic|robbery|burglary|prisoner|susp|derange|riot|total|kill", names(data), value = TRUE) 103 | month_cols <- month_cols[!grepl("indicator|employee", month_cols)] 104 | 105 | data <- agg_yearly(data, month_cols) 106 | data <- reorder_leoka_columns(data, crosswalk, type = "year") 107 | data$msa <- as.character(data$msa) 108 | leoka_yearly <- dplyr::bind_rows(leoka_yearly, data) 109 | message(data$year[1]); rm(data); gc(); Sys.sleep(3) 110 | } 111 | 112 | leoka_yearly <- 113 | leoka_yearly %>% 114 | dplyr::arrange(ori, 115 | desc(year)) 116 | 117 | # Save the data in various formats 118 | setwd(here::here("D:/ucr_data_storage/clean_data/LEOKA")) 119 | save_files(data = leoka_yearly, 120 | year = "1960_2021", 121 | file_name = "leoka_yearly_", 122 | save_name = "leoka_yearly_") 123 | 124 | return(leoka_yearly) 125 | } 126 | 127 | 128 | -------------------------------------------------------------------------------- /R/make_sps/make_arson_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | 3 | starting_nums <- c("1", 4 | "2-3", 5 | "4-10", 6 | "11-12", 7 | "13", 8 | "14-15", 9 | "16-20", 10 | "21", 11 | "22-28", 12 | "29", 13 | "30-32", 14 | "33-35", 15 | "36-40", 16 | "41-49", 17 | "50-51", 18 | "52-75", 19 | "76-81") 20 | 21 | starting_names <- c("identifier_code", 22 | "state", 23 | "ori", 24 | "population_group", 25 | "country_division", 26 | "year", 27 | "sequence_number", 28 | "core_city_indicator", 29 | "covered_by_ori", 30 | "covered_by_group", 31 | "msa", 32 | "county", 33 | "agency_count", 34 | "population", 35 | "number_of_months_reported", 36 | "agency_name", 37 | "state_name") 38 | 39 | 40 | monthly_indicator_nums <- c("82-83", 41 | "84-89", 42 | "90", 43 | "91", 44 | "92", 45 | "93", 46 | "94", 47 | "95", 48 | "96", 49 | "97", 50 | "98", 51 | "99", 52 | "100", 53 | "101", 54 | "102", 55 | "103") 56 | 57 | monthly_indicator_names <- c("month_included_in", 58 | "date_of_last_update", 59 | "column_2_type", 60 | "column_3_type", 61 | "column_4_type", 62 | "column_5_type", 63 | "column_6_type", 64 | "column_7_type", 65 | "column_8_type", 66 | "column_2_pt", 67 | "column_3_pt", 68 | "column_4_pt", 69 | "column_5_pt", 70 | "column_6_pt", 71 | "column_7_pt", 72 | "column_8_pt") 73 | 74 | location_types <- c("single_occupancy", 75 | "other_residential", 76 | "storage", 77 | "industrial", 78 | "other_commercial", 79 | "community_public", 80 | "all_oth_structures", 81 | "total_structures", 82 | "motor_vehicles", 83 | "other_mobile", 84 | "total_mobile", 85 | "all_other", 86 | "grand_total") 87 | abandoned_types <- c("single_occupancy", 88 | "other_residential", 89 | "storage", 90 | "industrial", 91 | "other_commercial", 92 | "community_public", 93 | "all_oth_structures", 94 | "total_structures", 95 | "grand_total") 96 | single_month_names <- c(monthly_indicator_names, 97 | paste0("reported_", location_types), 98 | paste0("unfounded_", location_types), 99 | paste0("actual_", location_types), 100 | paste0("cleared_", location_types), 101 | paste0("cleared_18_", location_types), 102 | paste0("uninhabited_", abandoned_types), 103 | paste0("est_damage_", location_types)) 104 | 105 | 106 | monthly_names <- paste0("replace_", single_month_names) 107 | all_month_names <- repeated_label_replace_fixer(monthly_names, tolower(month.abb)) 108 | 109 | 110 | monthly_value_nums <- c("104-108", 111 | "109-113", 112 | "114-118", 113 | "119-123", 114 | "124-128", 115 | "129-133", 116 | "134-138", 117 | "139-143", 118 | "144-148", 119 | "149-153", 120 | "154-158", 121 | "159-163", 122 | "164-168") 123 | 124 | monthly_value_nums <- c(monthly_value_nums, 125 | setup_num_adder(monthly_value_nums, 126 | adder = 65, 127 | iterations = 4)) 128 | 129 | uninhabited_and_damage_nums <- c("429-433", 130 | "434-438", 131 | "439-443", 132 | "444-448", 133 | "449-453", 134 | "454-458", 135 | "459-463", 136 | "464-468", 137 | "469-473", 138 | "474-484", 139 | "485-495", 140 | "496-506", 141 | "507-517", 142 | "518-528", 143 | "529-539", 144 | "540-550", 145 | "551-561", 146 | "562-572", 147 | "573-583", 148 | "584-594", 149 | "595-605", 150 | "606-616") 151 | 152 | total_single_month_nums <- c(monthly_indicator_nums, 153 | monthly_value_nums, 154 | uninhabited_and_damage_nums) 155 | 156 | 157 | all_month_nums <- c(total_single_month_nums, 158 | setup_num_adder(total_single_month_nums, 159 | adder = 535, 160 | iterations = 11)) 161 | 162 | 163 | col_positions <- c(starting_nums, 164 | all_month_nums) 165 | 166 | col_labels <- c(starting_names, 167 | all_month_names) 168 | 169 | setwd(here::here("setup_files")) 170 | asciiSetupReader::make_sps_setup(file_name = "ucr_arson", 171 | col_positions = col_positions, 172 | col_labels = col_labels, 173 | value_labels = state_group_division_value_labels) 174 | -------------------------------------------------------------------------------- /R/make_sps/make_hate_crime_batch_header_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | 3 | batch_header_values <- c(state_group_division_value_labels, 4 | "country_region = ", 5 | "1 = North East", 6 | "2 = North Central", 7 | "3 = South", 8 | "4 = West", 9 | "agency_indicator = ", 10 | "0 = Covered-by Another Agency", 11 | "1 = City", 12 | "2 = County", 13 | "3 = University or College", 14 | "4 = State Police", 15 | "core_city = ", 16 | "Y = Yes", 17 | "N = No", 18 | "agency_nibrs_flag = ", 19 | " = Inactive", 20 | "A = Active", 21 | # State quarter activity 22 | "state_first_quarter_activity = ", 23 | "Z = Zero-Report was submitted", 24 | "I = Incident Report was submitted", 25 | " = No hate crime information", 26 | "state_second_quarter_activity = ", 27 | "Z = Zero-Report was submitted", 28 | "I = Incident Report was submitted", 29 | " = No hate crime information", 30 | "state_third_quarter_activity = ", 31 | "Z = Zero-Report was submitted", 32 | "I = Incident Report was submitted", 33 | " = No hate crime information", 34 | "state_fourth_quarter_activity = ", 35 | "Z = Zero-Report was submitted", 36 | "I = Incident Report was submitted", 37 | " = No hate crime information", 38 | # Federal quarter activity 39 | "federal_first_quarter_activity = ", 40 | "I = Incident report was submitted", 41 | " = No hate crime information", 42 | "federal_second_quarter_activity = ", 43 | "I = Incident report was submitted", 44 | " = No hate crime information", 45 | "federal_third_quarter_activity = ", 46 | "I = Incident report was submitted", 47 | " = No hate crime information", 48 | "federal_fourth_quarter_activity = ", 49 | "I = Incident report was submitted", 50 | " = No hate crime information") 51 | 52 | batch_header_values_labels <- c(state_group_division_value_labels, 53 | batch_header_values) 54 | 55 | 56 | 57 | col_positions <- c("1-2", 58 | "3-4", 59 | "5-13", 60 | "14-25", 61 | "26-33", 62 | "34-41", 63 | "42-71", 64 | "72-73", 65 | "74-75", 66 | "76", 67 | "77", 68 | "78", 69 | "79", 70 | "80-88", 71 | "89-92", 72 | "93-96", 73 | "97", 74 | "98-105", 75 | "106-114", 76 | "115-117", 77 | "118-120", 78 | "121-129", 79 | "130-138", 80 | "139-141", 81 | "142-144", 82 | "145-153", 83 | "154-162", 84 | "163-165", 85 | "166-168", 86 | "169-177", 87 | "178-186", 88 | "187-189", 89 | "190-192", 90 | "193-201", 91 | "202-210", 92 | "211-213", 93 | "214-216", 94 | "217-225", 95 | "226-229", 96 | "230", 97 | "231", 98 | "232", 99 | "233", 100 | "234", 101 | "235", 102 | "236", 103 | "237", 104 | "238-267", 105 | "268-270", 106 | "271-273", 107 | "274-276", 108 | "277-279", 109 | "280-282") 110 | 111 | col_labels <- c("hate_crime_record_type", 112 | "state", 113 | "ori9", 114 | "incident_number", 115 | "date_ori_was_added", 116 | "date_ori_went_nibrs", 117 | "city_name", 118 | "state_abbreviation", 119 | "population_group", 120 | "country_division", 121 | "country_region", 122 | "agency_indicator", 123 | "core_city", 124 | "covered_by_ori", 125 | "fbi_field_office", 126 | "judicial_district", 127 | "agency_nibrs_flag", 128 | "agency_inactive_date", 129 | 130 | "current_population_1", 131 | "ucr_county_code_1", 132 | "msa_code_1", 133 | "last_population_1", 134 | 135 | "current_population_2", 136 | "ucr_county_code_2", 137 | "msa_code_2", 138 | "last_population_2", 139 | 140 | "current_population_3", 141 | "ucr_county_code_3", 142 | "msa_code_3", 143 | "last_population_3", 144 | 145 | "current_population_4", 146 | "ucr_county_code_4", 147 | "msa_code_4", 148 | "last_population_4", 149 | 150 | "current_population_5", 151 | "ucr_county_code_5", 152 | "msa_code_5", 153 | "last_population_5", 154 | "year", 155 | "state_first_quarter_activity", 156 | "state_second_quarter_activity", 157 | "state_third_quarter_activity", 158 | "state_fourth_quarter_activity", 159 | "federal_first_quarter_activity", 160 | "federal_second_quarter_activity", 161 | "federal_third_quarter_activity", 162 | "federal_fourth_quarter_activity", 163 | "agency_name", 164 | "fips_county_code_1", 165 | "fips_county_code_2", 166 | "fips_county_code_3", 167 | "fips_county_code_4", 168 | "fips_county_code_5") 169 | 170 | setwd(here::here("setup_files")) 171 | make_sps_setup(file_name = "ucr_hate_crimes_batch_header.sps", 172 | col_positions = col_positions, 173 | col_labels = col_labels, 174 | value_labels = batch_header_values_labels) -------------------------------------------------------------------------------- /R/make_sps/make_human_trafficking_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | 3 | 4 | starting_nums <- c("1", 5 | "2-3", 6 | "4-10", 7 | "11-12", 8 | "13", 9 | "14-15", 10 | "16-20", 11 | "21", 12 | "22-28", 13 | "29", 14 | "30-33", 15 | "34-35", 16 | "36", 17 | "37-45", 18 | "46-69", 19 | "70-75", 20 | "76", 21 | "77", 22 | "78", 23 | "79", 24 | "80", 25 | "81", 26 | "82", 27 | "83", 28 | "84", 29 | "85", 30 | "86", 31 | "87") 32 | 33 | starting_names <- c("identifier_code", 34 | "state", 35 | "ori", 36 | "population_group", 37 | "country_division", 38 | "year", 39 | "sequence_number", 40 | "core_city_indication", 41 | "covered_by_ori", 42 | "covered_by_population_group", 43 | "fbi_field_office", 44 | "number_of_months_reported", 45 | "agency_count", 46 | "population", 47 | "agency_name", 48 | "agency_state_name", 49 | "jan_report_code", 50 | "feb_report_code", 51 | "mar_report_code", 52 | "apr_report_code", 53 | "may_report_code", 54 | "jun_report_code", 55 | "jul_report_code", 56 | "aug_report_code", 57 | "sep_report_code", 58 | "oct_report_code", 59 | "nov_report_code", 60 | "dec_report_code") 61 | 62 | 63 | monthly_nums <- c("88-92", 64 | "93-97", 65 | "98-102", 66 | "103-107", 67 | "108-112", 68 | "113-117", 69 | "118-122", 70 | "123-127", 71 | "128-132", 72 | "133-137", 73 | "138-142", 74 | "143-147", 75 | "148-152", 76 | "153-157", 77 | "158-162") 78 | 79 | monthly_names <- c("replace_reported_commercial_sex_acts", 80 | "replace_reported_involuntary_serv", 81 | "replace_reported_total", 82 | "replace_unfound_commercial_sex_acts", 83 | "replace_unfound_involuntary_serv", 84 | "replace_unfound_total", 85 | "replace_actual_commercial_sex_acts", 86 | "replace_actual_involuntary_serv", 87 | "replace_actual_total", 88 | "replace_tot_clr_commercial_sex_acts", 89 | "replace_tot_clr_involuntary_serv", 90 | "replace_tot_clr_total", 91 | "replace_clr_18_commercial_sex_acts", 92 | "replace_clr_18_involuntary_serv", 93 | "replace_clr_18_total") 94 | 95 | report_code_value_labels <- c("replace_report_code = ", 96 | "X = no human trafficking information reported", 97 | "Q = type 14, no report", 98 | "N = data received") 99 | report_code_value_labels <- repeated_label_replace_fixer(report_code_value_labels, 100 | tolower(month.abb)) 101 | 102 | all_month_names <- repeated_label_replace_fixer(monthly_names, tolower(month.abb)) 103 | 104 | all_month_nums <- c(monthly_nums, 105 | setup_num_adder(monthly_nums, 75, 11)) 106 | 107 | 108 | 109 | human_trafficking_value_labels <- c(state_group_division_value_labels, 110 | "core_city_indication = ", 111 | "Y = core city of MSA", 112 | "N = not core city of MSA", 113 | "covered_by_population_group = ", 114 | "0 = possessions", 115 | "1 = city 250,000+", 116 | "1A = city 1,000,000+", 117 | "1B = city 500,000 thru 999,999", 118 | "1C = city 250,000 thru 499,999", 119 | "2 = city 100,000 thru 249,999", 120 | "3 = city 50,000 thru 99,999", 121 | "4 = city 25,000 thru 49,999", 122 | "5 = city 10,000 thru 24,999", 123 | "6 = city 2,500 thru 9,999", 124 | "7 = city under 2,500", 125 | "8 = non-msa county", 126 | "8A = non-msa county 100,000+", 127 | "8B = non-msa county 25,000 thru 99,999", 128 | "8C = non-msa county 10,000 thru 24,999", 129 | "8D = non-msa county under 10,000", 130 | "8E = non-msa state police", 131 | "9 = msa-county", 132 | "9A = msa-county 100,000+", 133 | "9B = msa-county 25,000 thru 99,999", 134 | "9C = msa-county 10,000 thru 24,999", 135 | "9D = msa-county under 10,000", 136 | "9E = msa state police", 137 | report_code_value_labels) 138 | 139 | col_positions <- c(starting_nums, 140 | all_month_nums) 141 | 142 | col_labels <- c(starting_names, 143 | all_month_names) 144 | 145 | setwd(here::here("setup_files")) 146 | make_sps_setup(file_name = "human_trafficking", 147 | col_positions = col_positions, 148 | col_labels = col_labels, 149 | value_labels = human_trafficking_value_labels) -------------------------------------------------------------------------------- /R/make_sps/make_nibrs_batch_header_1_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | source(here::here('R/make_sps/nibrs_sps_utils.R')) 3 | # Page 20-32 4 | 5 | county <- c("106-114", 6 | "115-117", 7 | "118-120", 8 | "121-129") 9 | county <- c(county, setup_num_adder(county, 24, 4)) 10 | month <- c("234-234", 11 | "235-235", 12 | "236-236") 13 | month <- c(month, setup_num_adder(month, 3, 11)) 14 | col_positions <- c("1-2", 15 | "3-4", 16 | "5-13", 17 | "14-25", 18 | "26-33", 19 | "34-41", 20 | "42-71", 21 | "72-73", 22 | "74-75", 23 | "76-76", 24 | "77-77", 25 | "78-78", 26 | "79-79", 27 | "80-88", 28 | "89-92", 29 | "93-96", 30 | "97-97", 31 | "98-105", 32 | county, 33 | "226-227", 34 | "228-229", 35 | "230-233", 36 | month, 37 | "270-272", 38 | "273-275", 39 | "276-278", 40 | "279-281", 41 | "282-284") 42 | 43 | 44 | col_labels <- c("segment_level", 45 | "state", 46 | "ori", 47 | "incident_number", 48 | "date_ori_was_added", 49 | "date_ori_went_nibrs", 50 | "city_name", 51 | "state_abbreviation", 52 | "population_group", 53 | "country_division", 54 | "country_region", 55 | "agency_indicator", 56 | "core_city", 57 | "covered_by_ori", 58 | "fbi_field_office", 59 | "judicial_district", 60 | "agency_nibrs_flag", 61 | "agency_inactive_date", 62 | paste0(rep(c("current_population_", 63 | "ucr_county_code_", 64 | "msa_code_", 65 | "last_population_"), 5), 66 | sort(rep(1:5, 4))), 67 | "x01_06_12_indicator", 68 | "number_of_months_reported", 69 | "year", 70 | paste0(rep(tolower(month.name), each = 3), c("_zero_report_submitted", 71 | "_group_a_b_submitted", 72 | "_window_record_submitted")), 73 | paste0("fips_county_code_", 1:5)) 74 | 75 | 76 | country_region <- c("country_region = ", 77 | "1 = north east", 78 | "2 = north central", 79 | "3 = south", 80 | "4 = west", 81 | "agency_indicator = ", 82 | "0 = covered-by another agency", 83 | "1 = city", 84 | "2 = county", 85 | "3 = university or college", 86 | "4 = state police", 87 | "6 = other agencies", 88 | "7 = tribal", 89 | "8 = federal", 90 | "core_city = ", 91 | "y = yes", 92 | "n = no", 93 | "judicial_district = ", 94 | "nnnn = northern", 95 | "nnns = southern", 96 | "nnne = eastern", 97 | "nnnw = western", 98 | "nnnm = middle", 99 | "nnnc = central", 100 | "nnna = entire state", 101 | "agency_nibrs_flag = ", 102 | "blank = does not yet participate", 103 | " = does not yet participate", 104 | "a = active", 105 | "x01_06_12_indicator = ", 106 | " = no months reported", 107 | "01 = 1 or more months reported", 108 | "06 = 6 or more months reported", 109 | "12 = 12 months reported") 110 | 111 | 112 | 113 | nibrs_batch_header_1_value_labels <- 114 | c(state_value_labels, 115 | state_group_division_value_labels, 116 | country_region, 117 | agency_activity_indicators) 118 | 119 | setwd(here::here("setup_files")) 120 | make_sps_setup(file_name = "nibrs_batch_header_1", 121 | col_positions = col_positions, 122 | col_labels = col_labels, 123 | value_labels = nibrs_batch_header_1_value_labels) -------------------------------------------------------------------------------- /R/make_sps/make_nibrs_batch_header_2_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | 3 | col_positions <- c("1-2", 4 | "3-4", 5 | "5-13", 6 | "14-25", 7 | "26-34", 8 | "35-37", 9 | "38-40", 10 | "41-49", 11 | "50-58", 12 | "59-61", 13 | "62-64", 14 | "65-73", 15 | "74-82", 16 | "83-85", 17 | "86-88", 18 | "89-97", 19 | "98-106", 20 | "107-109", 21 | "110-112", 22 | "113-121", 23 | "122-132") 24 | 25 | col_labels <- c("segment_level", 26 | "state", 27 | "ori", 28 | "incident_number", 29 | "current_population_1", 30 | "ucr_county_code_1", 31 | "msa_code_1", 32 | "last_population_1", 33 | "current_population_2", 34 | "ucr_county_code_2", 35 | "msa_code_2", 36 | "last_population_2", 37 | "current_population_3", 38 | "ucr_county_code_3", 39 | "msa_code_3", 40 | "last_population_3", 41 | "current_population_4", 42 | "ucr_county_code_4", 43 | "msa_code_4", 44 | "last_population_4", 45 | "blank") 46 | 47 | setwd(here::here("setup_files")) 48 | make_sps_setup(file_name = "nibrs_batch_header_2", 49 | col_positions = col_positions, 50 | col_labels = col_labels, 51 | value_labels = state_value_labels) -------------------------------------------------------------------------------- /R/make_sps/make_nibrs_batch_header_3_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | 3 | 4 | month <- c("58-58", 5 | "59-59", 6 | "60-60") 7 | col_positions <- c("1-2", 8 | "3-4", 9 | "5-13", 10 | "14-25", 11 | "26-34", 12 | "35-37", 13 | "38-40", 14 | "41-49", 15 | "50-51", 16 | "52-53", 17 | "54-57", 18 | month <- c(month, setup_num_adder(month, 3, 11)), 19 | "94-96", 20 | "97-99", 21 | "100-102", 22 | "103-105", 23 | "106-108", 24 | "109-132") 25 | 26 | 27 | col_labels <- c("segment_level", 28 | "state", 29 | "ori", 30 | "incident_number", 31 | "current_population_5", 32 | "ucr_county_code_5", 33 | "msa_code_5", 34 | "last_population_5", 35 | "01_06_12_indicator", 36 | "number_of_months_reported", 37 | "master_file_year", 38 | paste0(rep(tolower(month.name), each = 3), c("_zero_report_submitted", 39 | "_group_a_b_submitted", 40 | "_window_record_submitted")), 41 | paste0("fips_county_code_", 1:5), 42 | "blank") 43 | 44 | 45 | setwd(here::here("setup_files")) 46 | make_sps_setup(file_name = "nibrs_batch_header_3", 47 | col_positions = col_positions, 48 | col_labels = col_labels, 49 | value_labels = c(state_value_labels, 50 | agency_activity_indicators)) -------------------------------------------------------------------------------- /R/make_sps/make_sps_utils.R: -------------------------------------------------------------------------------- 1 | library(asciiSetupReader) 2 | library(readr) 3 | 4 | repeated_label_replace_fixer <- function(labels, replace_values) { 5 | final <- c() 6 | for (replace_value in replace_values) { 7 | final <- c(final, 8 | gsub("replace", replace_value, labels)) 9 | } 10 | return(final) 11 | } 12 | 13 | # For making sps files 14 | setup_num_adder <- function(data, adder, iterations, initial_adder_bump = 0) { 15 | adder_temp <- adder 16 | adder <- adder + initial_adder_bump 17 | final <- c() 18 | for (i in 1:iterations) { 19 | numbers_start <- stringr::str_split_fixed(data, "-", 2)[, 1] 20 | numbers_start <- as.numeric(numbers_start) 21 | 22 | numbers_end <- stringr::str_split_fixed(data, "-", 2)[, 2] 23 | numbers_end <- as.numeric(numbers_end) 24 | numbers_end[is.na(numbers_end)] <- numbers_start[is.na(numbers_end)] 25 | 26 | numbers_start <- numbers_start + adder 27 | numbers_end <- numbers_end + adder 28 | temp <- paste0(numbers_start, "-", numbers_end) 29 | final <- c(final, temp) 30 | adder <- adder + adder_temp 31 | 32 | } 33 | return(final) 34 | } 35 | 36 | check_raw_length <- function() { 37 | files <- list.files() 38 | files <- files[grepl("txt|dat$", files, ignore.case = TRUE)] 39 | for (file in files) { 40 | message(file) 41 | z <- readr::read_lines(file) 42 | 43 | # Gets rid of weird characters 44 | z = iconv(z, to = 'ASCII//TRANSLIT') 45 | print(table(nchar(z))) 46 | rm(z); gc() 47 | } 48 | } 49 | 50 | state_value_labels <- c("state = ", 51 | "50 = Alaska", 52 | "01 = Alabama", 53 | "03 = Arkansas", 54 | "54 = American Samoa", 55 | "02 = Arizona", 56 | "04 = California", 57 | "05 = Colorado", 58 | "06 = Connecticut", 59 | "52 = Canal Zone", 60 | "08 = District of Columbia", 61 | "07 = Delaware", 62 | "09 = Florida", 63 | "10 = Georgia", 64 | "55 = Guam", 65 | "51 = Hawaii", 66 | "14 = Iowa", 67 | "11 = Idaho", 68 | "12 = Illinois", 69 | "13 = Indiana", 70 | "15 = Kansas", 71 | "16 = Kentucky", 72 | "17 = Louisiana", 73 | "20 = Massachusetts", 74 | "19 = Maryland", 75 | "18 = Maine", 76 | "21 = Michigan", 77 | "22 = Minnesota", 78 | "24 = Missouri", 79 | "23 = Mississippi", 80 | "25 = Montana", 81 | "26 = Nebraska", 82 | "32 = North Carolina", 83 | "33 = North Dakota", 84 | "28 = New Hampshire", 85 | "29 = New Jersey", 86 | "30 = New Mexico", 87 | "27 = Nevada", 88 | "31 = New York", 89 | "34 = Ohio", 90 | "35 = Oklahoma", 91 | "36 = Oregon", 92 | "37 = Pennsylvania", 93 | "53 = Puerto Rico", 94 | "38 = Rhode Island", 95 | "39 = South Carolina", 96 | "40 = South Dakota", 97 | "41 = Tennessee", 98 | "42 = Texas", 99 | "43 = Utah", 100 | "62 = Virgin Islands", 101 | "45 = Virginia", 102 | "44 = Vermont", 103 | "46 = Washington", 104 | "48 = Wisconsin", 105 | "47 = West Virginia", 106 | "49 = Wyoming") 107 | state_group_division_value_labels <- c(state_value_labels, 108 | "population_group = ", 109 | "0 = possessions", 110 | "1 = city 250,000+", 111 | "1A = city 1,000,000+", 112 | "1B = city 500,000 thru 999,999", 113 | "1C = city 250,000 thru 499,999", 114 | "2 = city 100,000 thru 249,999", 115 | "3 = city 50,000 thru 99,999", 116 | "4 = city 25,000 thru 49,999", 117 | "5 = city 10,000 thru 24,999", 118 | "6 = city 2,500 thru 9,999", 119 | "7 = city under 2,500", 120 | "8 = non-msa county", 121 | "8A = non-msa county 100,000+", 122 | "8B = non-msa county 25,000 thru 99,999", 123 | "8C = non-msa county 10,000 thru 24,999", 124 | "8D = non-msa county under 10,000", 125 | "8E = non-msa state police", 126 | "9 = msa-county", 127 | "9A = msa-county 100,000+", 128 | "9B = msa-county 25,000 thru 99,999", 129 | "9C = msa-county 10,000 thru 24,999", 130 | "9D = msa-county under 10,000", 131 | "9E = msa state police", 132 | "country_division = ", 133 | "0 = Possessions", 134 | "1 = New England", 135 | "2 = Middle Atlantic", 136 | "3 = East North Central", 137 | "4 = West North Central", 138 | "5 = South Atlantic", 139 | "6 = East South Central", 140 | "7 = West South Central", 141 | "8 = Mountain", 142 | "9 = Pacific", 143 | "A = New England", 144 | "B = Middle Atlantic", 145 | "C = East North Central", 146 | "D = West North Central", 147 | "E = South Atlantic", 148 | "F = East South Central", 149 | "G = West South Central", 150 | "H = Mountain", 151 | "I = Pacific") 152 | 153 | 154 | -------------------------------------------------------------------------------- /R/make_sps/nibrs_administrative_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | source(here::here('R/make_sps/nibrs_sps_utils.R')) 3 | # Page 42-45 4 | 5 | col_positions <- c("1-2", 6 | "3-4", 7 | "5-13", 8 | "14-25", 9 | "26-33", 10 | "34", 11 | "35-36", 12 | "37-38", 13 | "39-41", 14 | "42-43", 15 | "44-45", 16 | "46-49", 17 | "50", 18 | "51-58") 19 | 20 | col_labels <- c("segment_level", 21 | "state", 22 | "ori", 23 | "incident_number", 24 | "incident_date", 25 | "report_date_indicator", 26 | "incident_date_hour", 27 | "total_offense_segments", 28 | "total_victim_segments", 29 | "total_offender_segments", 30 | "total_arrestee_segments", 31 | "city_submissions", 32 | "cleared_exceptionally", 33 | "exceptional_clearance_date") 34 | 35 | nibrs_administrative_segment_value_labels <- 36 | c(state_value_labels, 37 | "report_date_indicator = ", 38 | "R = report date", 39 | " = incident date", 40 | "incident_date_hour = ", 41 | "00 = on or between midnight and 00:59", 42 | "01 = on or between 01:00 and 01:59", 43 | "02 = on or between 02:00 and 02:59", 44 | "03 = on or between 03:00 and 03:59", 45 | "04 = on or between 04:00 and 04:59", 46 | "05 = on or between 05:00 and 05:59", 47 | "06 = on or between 06:00 and 06:59", 48 | "07 = on or between 07:00 and 07:59", 49 | "08 = on or between 08:00 and 08:59", 50 | "09 = on or between 09:00 and 09:59", 51 | "10 = on or between 10:00 and 10:59", 52 | "11 = on or between 11:00 and 11:59", 53 | "12 = on or between 12:00 and 12:59", 54 | "13 = on or between 13:00 and 13:59", 55 | "14 = on or between 14:00 and 14:59", 56 | "15 = on or between 15:00 and 15:59", 57 | "16 = on or between 16:00 and 16:59", 58 | "17 = on or between 17:00 and 17:59", 59 | "18 = on or between 18:00 and 18:59", 60 | "19 = on or between 19:00 and 19:59", 61 | "20 = on or between 20:00 and 20:59", 62 | "21 = on or between 21:00 and 21:59", 63 | "22 = on or between 22:00 and 22:59", 64 | "23 = on or between 23:00 and 23:59", 65 | "cleared_exceptionally = ", 66 | "A = death of offender", 67 | "B = prosecution declined (for other than lack of probable cause)", 68 | "C = extradition denied", 69 | "D = victim refused to cooperate", 70 | "E = juvenile/no custody", 71 | "N = not applicable") 72 | 73 | setwd(here::here("setup_files")) 74 | make_sps_setup(file_name = "nibrs_administrative_segment", 75 | col_positions = col_positions, 76 | col_labels = col_labels, 77 | value_labels = nibrs_administrative_segment_value_labels) -------------------------------------------------------------------------------- /R/make_sps/nibrs_arrestee_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | source(here::here('R/make_sps/nibrs_sps_utils.R')) 3 | # Page 72-77 4 | 5 | col_positions <- c("1-2", 6 | "3-4", 7 | "5-13", 8 | "14-25", 9 | "26-33", 10 | "34-35", 11 | "36-47", 12 | "48-55", 13 | "56", 14 | "57", 15 | "58-60", 16 | "61-62", 17 | "63", 18 | "64-65", 19 | "66", 20 | "67-68", 21 | "69", 22 | "70", 23 | "71", 24 | "72", 25 | "73") 26 | 27 | 28 | col_labels <- c("segment_level", 29 | "state", 30 | "ori", 31 | "incident_number", 32 | "incident_date", 33 | "arrestee_sequence_number", 34 | "arrest_transaction_number", 35 | "arrest_date", 36 | "type_of_arrest", 37 | "multiple_arrestee_indicator", 38 | "ucr_arrest_offense_code", 39 | "arrestee_weapon_1", 40 | "automatic_weapon_indicator_1", 41 | "arrestee_weapon_2", 42 | "automatic_weapon_indicator_2", 43 | "age_of_arrestee", 44 | "sex_of_arrestee", 45 | "race_of_arrestee", 46 | "ethnicity_of_arrestee", 47 | "resident_status_of_arrestee", 48 | "disposition_of_arrestee_under18") 49 | 50 | nibrs_arrestee_value_labels <- 51 | c(state_value_labels, 52 | "type_of_arrest = ", 53 | "O = on-view arrest (taken into custody without a warrant or previous incident report)", 54 | "S = summoned/cited (not taken into custody)", 55 | "T = taken into custody (based on warrant and/or previous incident report)", 56 | gsub("ucr_offense_code", "ucr_arrest_offense_code", ucr_offense_code_value_labels), 57 | repeated_label_replace_fixer(c("arrestee_weapon_replace = ", 58 | "01 = unarmed", 59 | "11 = firearm (type not stated)", 60 | "12 = handgun", 61 | "13 = rifle", 62 | "14 = shotgun", 63 | "15 = other firearm", 64 | "16 = lethal cutting instrument (e.g. switchblade knife, etc.)", 65 | "17 = club/blackjack/brass knuckles", 66 | "automatic_weapon_indicator_replace = ", 67 | "A = automatic weapon"), 1:2), 68 | gsub("replace", "arrestee", age_sex_race_ethnicity), 69 | "resident_status_of_arrestee = ", 70 | "R = resident", 71 | "r = resident", 72 | "N = nonresident", 73 | "U = unknown", 74 | "disposition_of_arrestee_under18 = ", 75 | "H = handled within department (released to parents, released with warning, etc.)", 76 | "R = referred to other authorities (turned over to juvenile court, probation department, welfare agency, other police agency, criminal or adult court, etc.)", 77 | "multiple_arrestee_indicator = ", 78 | "M = multiple", 79 | "m = multiple", 80 | "C = count arrestee", 81 | "c = count arrestee", 82 | "N = not applicable") 83 | 84 | setwd(here::here("setup_files")) 85 | make_sps_setup(file_name = "nibrs_arrestee_segment", 86 | col_positions = col_positions, 87 | col_labels = col_labels, 88 | value_labels = nibrs_arrestee_value_labels) 89 | -------------------------------------------------------------------------------- /R/make_sps/nibrs_group_b_arrest_report_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/nibrs_arrestee_segment_sps.R')) 2 | # Page 78-82 3 | 4 | col_positions <- c("1-2", 5 | "3-4", 6 | "5-13", 7 | "14-25", 8 | "26-33", 9 | "34-35", 10 | "36-39", 11 | "40", 12 | "41-43", 13 | "44-45", 14 | "46", 15 | "47-48", 16 | "49", 17 | "50-51", 18 | "52", 19 | "53", 20 | "54", 21 | "55", 22 | "56") 23 | 24 | 25 | col_labels <- c("segment_level", 26 | "state", 27 | "ori", 28 | "arrest_transaction_incident_num", 29 | "arrest_date", 30 | "arrestee_sequence_number", 31 | "city_submission", 32 | "type_of_arrest", 33 | "ucr_arrest_offense_code", 34 | "arrestee_weapon_1", 35 | "automatic_weapon_indicator_1", 36 | "arrestee_weapon_2", 37 | "automatic_weapon_indicator_2", 38 | "age_of_arrestee", 39 | "sex_of_arrestee", 40 | "race_of_arrestee", 41 | "ethnicity_of_arrestee", 42 | "resident_status_of_arrestee", 43 | "disposition_of_arrestee_under18") 44 | 45 | 46 | 47 | setwd(here::here("setup_files")) 48 | make_sps_setup(file_name = "nibrs_group_b_arrest_report_segment", 49 | col_positions = col_positions, 50 | col_labels = col_labels, 51 | value_labels = c(nibrs_arrestee_value_labels[1:180])) -------------------------------------------------------------------------------- /R/make_sps/nibrs_offender_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | source(here::here('R/make_sps/nibrs_sps_utils.R')) 3 | # Page 70-71 4 | 5 | 6 | col_positions <- c("1-2", 7 | "3-4", 8 | "5-13", 9 | "14-25", 10 | "26-33", 11 | "34-35", 12 | "36-37", 13 | "38", 14 | "39", 15 | "40") 16 | 17 | col_labels <- c("segment_level", 18 | "state", 19 | "ori", 20 | "incident_number", 21 | "incident_date", 22 | "offender_sequence_number", 23 | "age_of_offender", 24 | "sex_of_offender", 25 | "race_of_offender", 26 | "ethnicity_of_offender") 27 | 28 | nibrs_offender_value_labels <- c(state_value_labels, 29 | "offender_sequence_number = ", 30 | "00 = unknown", 31 | gsub("replace", "offender", age_sex_race_ethnicity)) 32 | 33 | setwd(here::here("setup_files")) 34 | make_sps_setup(file_name = "nibrs_offender_segment", 35 | col_positions = col_positions, 36 | col_labels = col_labels, 37 | value_labels = nibrs_offender_value_labels) -------------------------------------------------------------------------------- /R/make_sps/nibrs_offense_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | source(here::here('R/make_sps/nibrs_sps_utils.R')) 3 | # Page 46-53 4 | 5 | col_positions <- c("1-2", 6 | "3-4", 7 | "5-13", 8 | "14-25", 9 | "26-33", 10 | "34-36", 11 | "37", 12 | "38", 13 | "39", 14 | "40", 15 | "41-42", 16 | "43-44", 17 | "45", 18 | "46", 19 | "47", 20 | "48", 21 | "49-50", 22 | "51", 23 | "52-53", 24 | "54", 25 | "55-56", 26 | "57", 27 | "58-59") 28 | 29 | col_labels <- c("segment_level", 30 | "state", 31 | "ori", 32 | "incident_number", 33 | "incident_date", 34 | "ucr_offense_code", 35 | "offense_attempted_or_completed", 36 | "offender_suspected_of_using_1", 37 | "offender_suspected_of_using_2", 38 | "offender_suspected_of_using_3", 39 | "location_type", 40 | "number_of_premises_entered", 41 | "method_of_entry", 42 | "type_criminal_activity_1", 43 | "type_criminal_activity_2", 44 | "type_criminal_activity_3", 45 | "type_weapon_force_involved_1", 46 | "automatic_weapon_indicator_1", 47 | "type_weapon_force_involved_2", 48 | "automatic_weapon_indicator_2", 49 | "type_weapon_force_involved_3", 50 | "automatic_weapon_indicator_3", 51 | "bias_motivation") 52 | 53 | 54 | 55 | nibrs_offense_segment_value_labels_repeated <- 56 | c("offender_suspected_of_using_replace = ", 57 | "A = alcohol", 58 | "C = computer equipment", 59 | "D = drugs/narcotics", 60 | "N = not applicable", 61 | "type_criminal_activity_replace = ", 62 | "A = simple/gross neglect (unintentionally, intentionally, or knowingly failing to provide food, water, shelter, veterinary care, hoarding, etc.)", 63 | "B = buying/receiving", 64 | "C = cultivating/manufacturing/publishing", 65 | "D = distributing/selling", 66 | "E = exploiting children", 67 | "O = operating/promoting/assisting", 68 | "P = possessing/concealing", 69 | "T = transporting/transmitting/importing", 70 | "U = using/consuming", 71 | "I = intentional abuse and torture (tormenting, mutilating, poisoning, or abandonment)", 72 | "S = animal sexual abuse (bestiality)", 73 | "F = organized abuse (dog fighting and cock fighting)", 74 | # From NACJD 2016 offense segment file 75 | "N = none/unknown gang involvement (mutually exclusive)", 76 | "G = other gang", 77 | "J = juvenile gang involvement", 78 | "type_weapon_force_involved_replace = ", 79 | "11 = firearm (type not stated)", 80 | "12 = handgun", 81 | "13 = rifle", 82 | "14 = shotgun", 83 | "15 = other firearm", 84 | "20 = knife/cutting instrument (ice pick, screwdriver, ax, etc.)", 85 | "30 = blunt object (club, hammer, etc.)", 86 | "35 = motor vehicle", 87 | "40 = personal weapons (hands, feet, teeth, etc.)", 88 | "50 = poison (include gas)", 89 | "60 = explosives", 90 | "65 = fire/incendiary device", 91 | "70 = drugs/narcotics/sleeping pills", 92 | "85 = asphyxiation (by drowning, strangulation, suffocation, gas, etc.)", 93 | "90 = other", 94 | "95 = unknown", 95 | "99 = none", 96 | "automatic_weapon_indicator_replace = ", 97 | "A = automatic weapon") 98 | nibrs_offense_segment_value_labels_repeated <- 99 | repeated_label_replace_fixer(nibrs_offense_segment_value_labels_repeated, 100 | 1:3) 101 | 102 | nibrs_offense_segment_value_labels <- 103 | c(state_value_labels, 104 | "offense_attempted_or_completed = ", 105 | "A = attempted", 106 | "C = completed", 107 | "bias_motivation = ", 108 | "11 = anti-white", 109 | "12 = anti-black", 110 | "13 = anti-american indian or alaskan native", 111 | "14 = anti-asian", 112 | "15 = anti-multi-racial group", 113 | "21 = anti-jewish", 114 | "22 = anti-catholic", 115 | "23 = anti-protestant", 116 | "24 = anti-islamic (muslim)", 117 | "25 = anti-other religion", 118 | "26 = anti-multi-religious group", 119 | "27 = anti-atheism/agnosticism", 120 | "31 = anti-arab", 121 | "32 = anti-hispanic", 122 | "33 = anti-other race/ethnicity/national origin", 123 | "41 = anti-gay (male)", 124 | "42 = anti-lesbian (female)", 125 | "43 = anti-lesbian, gay, bisexual, or transgender (mixed group)", 126 | "44 = anti-heterosexual", 127 | "45 = anti-bisexual", 128 | "88 = no bias motivation", 129 | "99 = unknown bias motivation", 130 | # From NACJD 2016 offense segment file 131 | "16 = anti-native hawaiian or other pacific islander", 132 | "28 = anti-mormon", 133 | "29 = anti-jehovahs witness", 134 | "51 = anti-physical disability", 135 | "52 = anti-mental disability", 136 | "61 = anti-male", 137 | "62 = anti-female", 138 | "71 = anti-transgender", 139 | "72 = anti-gender non-conforming", 140 | "81 = anti-eastern orthodox (greek, russian, etc.)", 141 | "82 = anti-other christian", 142 | "83 = anti-buddhist", 143 | "84 = anti-hindu", 144 | "85 = anti-sikh", 145 | "method_of_entry = ", 146 | "F = force", 147 | "N = no force", 148 | location_type_value_labels, 149 | ucr_offense_code_value_labels, 150 | nibrs_offense_segment_value_labels_repeated) 151 | 152 | setwd(here::here("setup_files")) 153 | make_sps_setup(file_name = "nibrs_offense_segment", 154 | col_positions = col_positions, 155 | col_labels = col_labels, 156 | value_labels = nibrs_offense_segment_value_labels) 157 | -------------------------------------------------------------------------------- /R/make_sps/nibrs_property_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/make_sps_utils.R')) 2 | source(here::here('R/make_sps/nibrs_sps_utils.R')) 3 | # Page 54-61 4 | 5 | 6 | col_positions <- c("1-2", 7 | "3-4", 8 | "5-13", 9 | "14-25", 10 | "26-33", 11 | "34", 12 | "35-36", 13 | "37-45", 14 | "46-53", 15 | "54-55", 16 | "56-57", 17 | "58", 18 | "59-67", 19 | "68-70", 20 | "71-72", 21 | "73", 22 | "74-82", 23 | "83-85", 24 | "86-87", 25 | "88", 26 | "89-97", 27 | "98-100", 28 | "101-102") 29 | 30 | 31 | 32 | col_labels <- c("segment_level", 33 | "state", 34 | "ori", 35 | "incident_number", 36 | "incident_date", 37 | "type_of_property_loss", 38 | "property_description", 39 | "value_of_property", 40 | "date_recovered", 41 | "number_of_stolen_motor_vehicles", 42 | "num_of_recovered_motor_vehicles", 43 | "suspected_drug_type_1", 44 | "estimated_quantity_1", 45 | "est_quantity_fractional_1000th1", 46 | "type_of_measurement_1", 47 | "suspected_drug_type_2", 48 | "estimated_quantity_2", 49 | "est_quantity_fractional_1000th2", 50 | "type_of_measurement_2", 51 | "suspected_drug_type_3", 52 | "estimated_quantity_3", 53 | "est_quantity_fractional_1000th3", 54 | "type_of_measurement_3") 55 | 56 | nibrs_property_segment_value_labels <- c("type_of_measurement_replace = ", 57 | # Weight 58 | "GM = gram", 59 | "KG = kilogram", 60 | "OZ = ounce", 61 | "LB = pound", 62 | # Capacity 63 | "ML = milliliter", 64 | "LT = liter", 65 | "FO = fluid ounce", 66 | "GL = gallon", 67 | # Units 68 | "DU = dosage unit/items (pills, etc.)", 69 | "NP = number of plants", 70 | "XX = not reported", 71 | suspected_drug_type_value_labels_replace) 72 | nibrs_property_segment_value_labels <- repeated_label_replace_fixer(nibrs_property_segment_value_labels, 1:3) 73 | nibrs_property_segment_value_labels <- 74 | c(state_value_labels, 75 | nibrs_property_segment_value_labels, 76 | "type_of_property_loss = ", 77 | "1 = none", 78 | "2 = burned", 79 | "3 = counterfeited/forged", 80 | "4 = destroyed/damaged/vandalized", 81 | "5 = recovered", 82 | "6 = seized", 83 | "7 = stolen/etc. (includes bribed, defrauded, embezzled, extorted, ransomed, robbed, etc.)", 84 | "8 = unknown", 85 | "property_description = ", 86 | "01 = aircraft", 87 | "02 = alcohol", 88 | "03 = automobiles", 89 | "04 = bicycles", 90 | "05 = buses", 91 | "06 = clothes/furs", 92 | "07 = computer hardware/software", 93 | "08 = consumable goods", 94 | "09 = credit/debit cards", 95 | "10 = drugs/narcotics", 96 | "11 = drug/narcotic equipment", 97 | "12 = farm equipment", 98 | "13 = firearms", 99 | "14 = gambling equipment", 100 | "15 = heavy construction/industrial equipment", 101 | "16 = household goods", 102 | "17 = jewelry/precious metals", 103 | "18 = livestock", 104 | "19 = merchandise", 105 | "20 = money", 106 | "21 = negotiable instruments", 107 | "22 = nonnegotiable instruments", 108 | "23 = office-type equipment", 109 | "24 = other motor vehicles", 110 | "25 = purses/handbags/wallets", 111 | "26 = radios/TVs/VCRs", 112 | "27 = recordings - audio/visual", 113 | "28 = recreational vehicles", 114 | "29 = structures - single occupancy dwellings", 115 | "30 = structures - other dwellings", 116 | "31 = structures - commercial/business", 117 | "32 = structures - industrial manufacturing", 118 | "33 = structures - public/community", 119 | "34 = structures - storage", 120 | "35 = structures - other", 121 | "36 = tools - power/hand", 122 | "37 = trucks", 123 | "38 = vehicle parts/accessories", 124 | "39 = watercraft", 125 | "77 = other", 126 | "88 = pending inventory (of property)", 127 | "99 = special category", 128 | # From NACJD 2016 property segment file 129 | "41 = aircraft parts/accessories", 130 | "42 = artistic supplies/accessories", 131 | "43 = building materials", 132 | "44 = camping/hunting/fishing equipment/supplies", 133 | "45 = chemicals", 134 | "46 = collections/collectibles", 135 | "47 = crops", 136 | "48 = documents - personal or business", 137 | "49 = explosives", 138 | "59 = firearm accessories", 139 | "64 = fuel", 140 | "65 = identity documents", 141 | "66 = identity - intangible", 142 | "67 = law enforcement equipment", 143 | "68 = lawn/yard/garden equipment", 144 | "69 = logging equipment", 145 | "70 = medical/medical lab equipment", 146 | "71 = metals, non-precious", 147 | "72 = musical instruments", 148 | "73 = pets", 149 | "74 = photographic/optical equipment", 150 | "75 = portible electronic communications", 151 | "76 = recreational/sports equipment", 152 | "78 = trailers", 153 | "79 = watercraft equipment/parts/accessories", 154 | "80 = weapons - other", 155 | "value_of_property = ", 156 | "000000001 = unknown") 157 | 158 | setwd(here::here("setup_files")) 159 | make_sps_setup(file_name = "nibrs_property_segment", 160 | col_positions = col_positions, 161 | col_labels = col_labels, 162 | value_labels = nibrs_property_segment_value_labels) 163 | -------------------------------------------------------------------------------- /R/make_sps/nibrs_window_arrestee_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/nibrs_arrestee_segment_sps.R')) 2 | # Page 72-77 3 | 4 | col_positions <- c(col_positions, 5 | "74", 6 | "75-77", 7 | "78-80", 8 | "81-83", 9 | "84-86", 10 | "87-89", 11 | "90-92", 12 | "93-95", 13 | "96-98", 14 | "99-101", 15 | "102-104") 16 | 17 | col_labels <- c(col_labels, 18 | "window_clearance_flag", 19 | repeated_label_replace_fixer("ucr_offense_code_replace", 20 | 1:10)) 21 | 22 | nibrs_window_arrestee_segment_value_labels <- 23 | c(nibrs_arrestee_value_labels, 24 | "window_clearance_flag = ", 25 | "Y = yes (clears the case)", 26 | "N = no (already cleared)", 27 | repeated_label_replace_fixer(ucr_offense_code_value_labels_replace, 28 | 1:10)) 29 | 30 | setwd(here::here("setup_files")) 31 | make_sps_setup(file_name = "nibrs_window_arrestee_segment", 32 | col_positions = col_positions, 33 | col_labels = col_labels, 34 | value_labels = nibrs_window_arrestee_segment_value_labels) -------------------------------------------------------------------------------- /R/make_sps/nibrs_window_exceptional_clearance_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/nibrs_administrative_segment_sps.R')) 2 | # Page 42-45 3 | 4 | col_positions <- c(col_positions, 5 | "59-61", 6 | "62-64", 7 | "65-67", 8 | "68-70", 9 | "71-73", 10 | "74-76", 11 | "77-79", 12 | "80-82", 13 | "83-85", 14 | "86-88", 15 | "89") 16 | 17 | col_labels <- c(col_labels, 18 | repeated_label_replace_fixer("ucr_offense_code_replace", 19 | 1:10), 20 | "cargo_theft_indicator") 21 | 22 | nibrs_window_exceptional_clearance_segment_value_labels <- 23 | c(nibrs_administrative_segment_value_labels, 24 | repeated_label_replace_fixer(ucr_offense_code_value_labels_replace, 25 | 1:10), 26 | "cargo_theft_indicator = ", 27 | "Y = yes", 28 | "N = no" 29 | ) 30 | 31 | setwd(here::here("setup_files")) 32 | make_sps_setup(file_name = "nibrs_window_exceptional_clearance_segment", 33 | col_positions = col_positions, 34 | col_labels = col_labels, 35 | value_labels = nibrs_window_exceptional_clearance_segment_value_labels) -------------------------------------------------------------------------------- /R/make_sps/nibrs_window_recovered_property_segment_sps.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/make_sps/nibrs_property_segment_sps.R')) 2 | # Page 54-61 3 | 4 | col_positions <- c(col_positions, 5 | "103-105", 6 | "106-108", 7 | "109-111", 8 | "112-114", 9 | "115-117", 10 | "118-120", 11 | "121-123", 12 | "124-126", 13 | "127-129", 14 | "130-132") 15 | 16 | col_labels <- c(col_labels, 17 | repeated_label_replace_fixer("ucr_offense_code_replace", 18 | 1:10)) 19 | 20 | nibrs_window_property_segment_value_labels <- 21 | c(nibrs_property_segment_value_labels, 22 | repeated_label_replace_fixer(ucr_offense_code_value_labels_replace, 23 | 1:10)) 24 | 25 | setwd(here::here("setup_files")) 26 | make_sps_setup(file_name = "nibrs_window_recovered_property_segment", 27 | col_positions = col_positions, 28 | col_labels = col_labels, 29 | value_labels = nibrs_window_property_segment_value_labels) 30 | -------------------------------------------------------------------------------- /R/nibrs.R: -------------------------------------------------------------------------------- 1 | source(here::here('R/utils/global_utils.R')) 2 | source(here::here('R/utils/saving_utils.R')) 3 | 4 | 5 | nibrs_segments <- c("administrative_segment", 6 | "offense_segment", 7 | "property_segment", 8 | "victim_segment", 9 | "offender_segment", 10 | "arrestee_segment", 11 | "group_b_arrest_report_segment", 12 | "window_exceptional_clearance_segment", 13 | "window_recovered_property_segment", 14 | "window_arrestee_segment", 15 | "batch_header") 16 | 17 | 18 | 19 | read_and_save_nibrs_segments("property_segment", years = 2021) 20 | save_nibrs_as_zip("property_segment") 21 | save_nibrs_as_zip <- function(segments) { 22 | setwd("E:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 23 | for (segment in segments) { 24 | setwd("E:/ucr_data_storage/clean_data/nibrs") 25 | save_as_zip(paste0("nibrs_1991_2021_", segment, "_"), 26 | pattern = paste0("nibrs_", segment)) 27 | message(segment) 28 | } 29 | } 30 | 31 | 32 | read_and_save_nibrs_segments <- function(segments, years = NULL) { 33 | for (segment in segments) { 34 | 35 | 36 | source(here::here(paste0("R/make_sps/nibrs_", segment, "_sps.R"))) 37 | setwd("E:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 38 | files <- list.files(pattern = paste0("^", segment)) 39 | 40 | 41 | if (!is.null(years)) { 42 | files <- files[readr::parse_number(files) %in% years] 43 | } 44 | print(files) 45 | 46 | 47 | for (file in files) { 48 | setwd("E:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 49 | 50 | data <- read_ascii_setup(file, here::here(paste0("setup_files/nibrs_", 51 | segment, ".sps"))) 52 | 53 | data <- 54 | data %>% 55 | select(-segment_level) %>% 56 | mutate(state_abb = crimeutils::make_state_abb(state), 57 | state = tolower(state), 58 | year = parse_number(file)) %>% 59 | select(ori, 60 | year, 61 | state, 62 | state_abb, 63 | everything()) %>% 64 | arrange(ori) 65 | if ("incident_date" %in% names(data)) { 66 | data$incident_date <- ymd(data$incident_date) 67 | } 68 | # Arrestee segment 69 | if ("arrest_date" %in% names(data)) { 70 | data$arrest_date <- ymd(data$arrest_date) 71 | } 72 | # Administrative segment 73 | if ("exceptional_clearance_date" %in% names(data)) { 74 | data$exceptional_clearance_date <- ymd(data$exceptional_clearance_date) 75 | } 76 | # Property recovered segment 77 | if ("date_recovered" %in% names(data)) { 78 | data$date_recovered <- ymd(data$date_recovered) 79 | } 80 | data$city_submission <- NULL 81 | 82 | 83 | if (all(c("incident_number", "ori") %in% names(data))) { 84 | data$unique_incident_id <- paste(data$ori, data$incident_number) 85 | } 86 | 87 | 88 | setwd("E:/ucr_data_storage/clean_data/nibrs") 89 | save_files(data = data, 90 | year = unique(data$year), 91 | file_name = paste0("nibrs_", segment, "_"), 92 | save_name = paste0("nibrs_", segment, "_")) 93 | message(file) 94 | #print(names(data)) 95 | print(nrow(data)) 96 | #check_nibrs_data(data) 97 | rm(data); gc(); #Sys.sleep(5) 98 | } 99 | } 100 | } 101 | 102 | check_nibrs_data <- function(data) { 103 | summary(data$incident_date) 104 | data$incident_number <- NULL 105 | data$ori <- NULL 106 | data$incident_date <- NULL 107 | data$arrest_date <- NULL 108 | data$arrest_transaction_incident_num <- NULL 109 | data$arrest_transaction_number <- NULL 110 | data$arrestee_sequence_number <- NULL 111 | data$exceptional_clearance_date <- NULL 112 | data$date_recovered <- NULL 113 | data$unique_incident_id <- NULL 114 | print(sapply(data, function(x) sort(unique(x), na.last = TRUE))) 115 | message("\n\n\n\n") 116 | } 117 | 118 | # Check data 119 | files <- list.files(pattern = "2020.rds") 120 | files 121 | for (file in files) { 122 | data <- readRDS(file) 123 | message(file) 124 | check_nibrs_data(data) 125 | 126 | } 127 | 128 | 129 | -------------------------------------------------------------------------------- /R/nibrs_batch_header.R: -------------------------------------------------------------------------------- 1 | here::here("setup_files/nibrs_batch_header_1_segment.sps") 2 | library(here) 3 | source(here('R/utils/global_utils.R')) 4 | source(here('R/utils/saving_utils.R')) 5 | 6 | source("C:/Users/jkkap/Dropbox/R_project/crime_data/R/make_sps/make_nibrs_batch_header_1_sps.R") 7 | source("C:/Users/jkkap/Dropbox/R_project/crime_data/R/make_sps/make_nibrs_batch_header_2_sps.R") 8 | source("C:/Users/jkkap/Dropbox/R_project/crime_data/R/make_sps/make_nibrs_batch_header_3_sps.R") 9 | save_as_zip("nibrs_batch_headers_", pattern = "batch_header") 10 | library(dplyr) 11 | library(asciiSetupReader) 12 | library(readr) 13 | 14 | add_incident_num_spacing <- function(data, file) { 15 | data <- gsub('^(.{13})', '\\1zzzzzzzzzzzz', data) 16 | writeLines(data, file) 17 | } 18 | # 19 | # setwd("D:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 20 | # files <- list.files(pattern = "batch") 21 | # files 22 | 23 | # for (file in files) { 24 | # year_value <- gsub("batch_header_[0-9]_|batch_header_new_|.txt", "", file) 25 | # if (year_value >= 2017) { 26 | # next 27 | # } 28 | # file_name <- gsub(".txt", "_fixed.txt", file) 29 | # data <- read_lines(file) 30 | # add_incident_num_spacing(data, file_name) 31 | # message(file) 32 | # } 33 | 34 | 35 | 36 | setwd("D:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 37 | files <- list.files(pattern = "fixed|2017|2018|2019|202") 38 | files <- files[grep("batch", files)] 39 | files 40 | 41 | for (year_temp in 1991:2021) { 42 | setwd("D:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 43 | message(year_temp) 44 | if (year_temp >= 2013) { 45 | file <- files[grep(year_temp, files)] 46 | batch_header <- read_ascii_setup(file, 47 | here::here("setup_files/nibrs_batch_header_1.sps")) %>% 48 | dplyr::select(-segment_level, 49 | -incident_number) 50 | 51 | } else { 52 | batch_header_1 <- read_ascii_setup(paste0("batch_header_1_", year_temp, "_fixed.txt"), 53 | here::here("setup_files/nibrs_batch_header_1.sps")) %>% 54 | dplyr::select(state, 55 | ori, 56 | date_ori_was_added, 57 | date_ori_went_nibrs, 58 | city_name, 59 | state_abbreviation, 60 | population_group, 61 | country_division, 62 | country_region, 63 | agency_indicator, 64 | core_city, 65 | covered_by_ori, 66 | fbi_field_office, 67 | judicial_district, 68 | agency_nibrs_flag, 69 | agency_inactive_date) 70 | 71 | batch_header_2 <- read_ascii_setup(paste0("batch_header_2_", year_temp, "_fixed.txt"), 72 | here::here("setup_files/nibrs_batch_header_2.sps")) %>% 73 | dplyr::select(-segment_level, 74 | -state, 75 | -incident_number, 76 | -blank) 77 | 78 | batch_header_3 <- read_ascii_setup(paste0("batch_header_3_", year_temp, "_fixed.txt"), 79 | here::here("setup_files/nibrs_batch_header_3.sps")) %>% 80 | dplyr::select(-segment_level, 81 | -state, 82 | -incident_number, 83 | -fips_county_code_1, 84 | -fips_county_code_2, 85 | -fips_county_code_3, 86 | -fips_county_code_4, 87 | -fips_county_code_5, 88 | -blank) 89 | batch_header <- 90 | batch_header_1 %>% 91 | left_join(batch_header_2) %>% 92 | left_join(batch_header_3) 93 | } 94 | 95 | for (i in 1:ncol(batch_header)) { 96 | batch_header$temp <- batch_header[, i] 97 | batch_header$temp <- gsub(" V[0-9]{2}$", "", batch_header$temp) 98 | batch_header[, i] <- batch_header$temp 99 | batch_header$temp <- NULL 100 | } 101 | if (-any(grepl("year", names(batch_header)))) { 102 | batch_header$year <- year_temp 103 | } 104 | 105 | batch_header <- 106 | batch_header %>% 107 | dplyr::mutate(current_population_1 = as.numeric(current_population_1), 108 | current_population_2 = as.numeric(current_population_2), 109 | current_population_3 = as.numeric(current_population_3), 110 | current_population_4 = as.numeric(current_population_4), 111 | current_population_5 = as.numeric(current_population_5)) %>% 112 | dplyr::mutate(population = current_population_1 + 113 | current_population_2 + 114 | current_population_3 + 115 | current_population_4 + 116 | current_population_5) %>% 117 | dplyr::select(ori, 118 | year, 119 | state, 120 | population, 121 | everything()) %>% 122 | dplyr::rename(september_window_record_submitte = september_window_record_submitted) 123 | 124 | setwd("D:/ucr_data_storage/clean_data/nibrs") 125 | save_files(data = batch_header, 126 | year = unique(batch_header$year), 127 | file_name = "nibrs_batch_header_", 128 | save_name = "nibrs_batch_header_") 129 | 130 | } 131 | -------------------------------------------------------------------------------- /R/offenses_known.R: -------------------------------------------------------------------------------- 1 | source('R/crosswalk.R') 2 | source('R/utils/global_utils.R') 3 | source('R/utils/offenses_known_utils.R') 4 | source('R/make_sps/make_offenses_known_sps.R') 5 | crosswalk <- read_merge_crosswalks() 6 | 7 | get_all_return_a_monthly(crosswalk) 8 | offenses_known_yearly <- get_data_yearly("offenses_known", 9 | "1960_2021", 10 | "offenses_known_yearly_", 11 | crosswalk) 12 | table(offenses_known_yearly$year) 13 | sort(unique(offenses_known_yearly$year)) 14 | global_checks(offenses_known_yearly) 15 | table(offenses_known_yearly$number_of_months_missing == offenses_known_yearly$arson_number_of_months_missing) 16 | 17 | summary(offenses_known_yearly$actual_murder[offenses_known_yearly$year %in% 2019]) 18 | summary(offenses_known_yearly$actual_murder[offenses_known_yearly$year %in% 2021]) 19 | summary(offenses_known_yearly$actual_robbery_total[offenses_known_yearly$year %in% 2019]) 20 | summary(offenses_known_yearly$actual_robbery_total[offenses_known_yearly$year %in% 2021]) 21 | summary(offenses_known_yearly$officers_assaulted[offenses_known_yearly$year %in% 2019]) 22 | summary(offenses_known_yearly$officers_assaulted[offenses_known_yearly$year %in% 2021]) 23 | summary(offenses_known_yearly$clr_18_burg_total[offenses_known_yearly$year %in% 2019]) 24 | summary(offenses_known_yearly$clr_18_burg_total[offenses_known_yearly$year %in% 2021]) 25 | summary(offenses_known_yearly$actual_murder[offenses_known_yearly$year %in% 2019]) 26 | summary(offenses_known_yearly$actual_murder[offenses_known_yearly$year %in% 2021]) 27 | 28 | setwd(here("E:/ucr_data_storage/clean_data/offenses_known")) 29 | save_as_zip("ucr_offenses_known_monthly_1960_2021_", pattern = "month") 30 | save_as_zip("ucr_offenses_known_yearly_1960_2021_", pattern = "year") 31 | 32 | get_all_return_a_monthly <- function(crosswalk) { 33 | setwd("E:/ucr_data_storage/raw_data/offenses_known_from_fbi") 34 | files <- list.files() 35 | print(files) 36 | 37 | for (file in files[c(44, 1:3)]) { 38 | setwd("E:/ucr_data_storage/raw_data/offenses_known_from_fbi") 39 | data <- read_ascii_setup(file, here("setup_files/ucr_return_a.sps")) 40 | 41 | data <- 42 | data %>% 43 | filter(!is.na(ori)) %>% 44 | dplyr::select(-identifier_code, 45 | -population_source, 46 | -contains("last_population"), 47 | -contains("under50"), 48 | -population_1_msa, 49 | -population_2_msa, 50 | -population_3_msa, 51 | -population_source, 52 | -sequence_number, 53 | -agency_state_name, 54 | -covered_by_population_group, 55 | -contains("blank"), 56 | -population_group_in_previous_year) %>% 57 | mutate_at(vars(tidyselect::matches("card")), 58 | remove_special_characters) %>% 59 | mutate_at(vars(tidyselect::matches("mail")), 60 | crime_remove_special_characters) %>% 61 | mutate_if(is.character, tolower) %>% 62 | mutate(year = fix_years(year), 63 | population = population_1 + population_2 + population_3, 64 | ori = toupper(ori), 65 | state_abb = make_state_abb(state), 66 | covered_by_ori = as.character(covered_by_ori)) %>% 67 | # for some reason in 2019 there are a bunch of agencies with duplicate 68 | # rows 69 | distinct(ori, .keep_all = TRUE) 70 | 71 | data <- fix_all_negatives(data); Sys.sleep(3) 72 | data <- fix_outliers(data) 73 | data <- month_wide_to_long(data) 74 | 75 | if (data$year[1] == 2017) { 76 | data$unfound_burg_attempted[data$ori %in% "LANPD00"] <- NA 77 | data$unfound_burg_total[data$ori %in% "LANPD00"] <- NA 78 | } 79 | data <- make_agg_assault(data) 80 | 81 | # Get arson data 82 | if (data$year[1] >= 1979) { 83 | arson <- readRDS(paste0("E:/ucr_data_storage/clean_data/arson/ucr_arson_monthly_", data$year[1], ".rds")) 84 | arson <- 85 | arson %>% 86 | select(ori, 87 | year, 88 | month, 89 | number_of_months_missing, 90 | last_month_reported, 91 | dplyr::starts_with("actual"), 92 | dplyr::starts_with("cleared"), 93 | dplyr::starts_with("cleared_18"), 94 | dplyr::starts_with("unfound")) %>% 95 | rename(arson_number_of_months_missing = number_of_months_missing, 96 | arson_last_month_reported = last_month_reported) 97 | names(arson) <- gsub("^cleared_18", "clr_18_arson", names(arson)) 98 | names(arson) <- gsub("^cleared", "tot_clr_arson", names(arson)) 99 | names(arson) <- gsub("^actual", "actual_arson", names(arson)) 100 | names(arson) <- gsub("^unfounded", "unfound_arson", names(arson)) 101 | 102 | data <- left_join(data, arson, by = c("ori", "year", "month")) 103 | 104 | data$actual_all_crimes <- data$actual_all_crimes + data$actual_arson_grand_total 105 | data$tot_clr_all_crimes <- data$tot_clr_all_crimes + data$tot_clr_arson_grand_total 106 | data$clr_18_all_crimes <- data$clr_18_all_crimes + data$clr_18_arson_grand_total 107 | data$unfound_all_crimes <- data$unfound_all_crimes + data$unfound_arson_grand_total 108 | } 109 | data <- make_index_crimes(data) 110 | data$juvenile_age[data$juvenile_age == 0] <- NA 111 | 112 | data <- fix_number_of_months_reported(data) 113 | data <- get_months_missing_annual(data) 114 | data$number_of_months_reported <- NULL 115 | 116 | data <- left_join(data, crosswalk, by = "ori") 117 | data <- reorder_columns(data, crosswalk) 118 | data$population_group[data$population_group %in% "7b"] <- NA 119 | 120 | data$state[data$state %in% c("69", "98", "99")] <- NA 121 | 122 | # Save the data in various formats 123 | setwd(here("E:/ucr_data_storage/clean_data/offenses_known")) 124 | save_files(data = data, 125 | year = data$year[1], 126 | file_name = "offenses_known_monthly_", 127 | save_name = "offenses_known_monthly_") 128 | message(data$year[1]) 129 | rm(data); gc(); Sys.sleep(1) 130 | 131 | 132 | } 133 | } 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /R/parse_raw_nibrs_master_files.R: -------------------------------------------------------------------------------- 1 | source('R/utils/global_utils.R') 2 | setwd("D:/ucr_data_storage/raw_data/nibrs_from_fbi") 3 | 4 | 5 | files <- list.files() 6 | files <- data.frame(file = files, 7 | year = readr::parse_number(files)) 8 | files <- 9 | files %>% 10 | mutate(year = fix_years(year)) %>% 11 | arrange(year) 12 | files 13 | segment_levels <- data.frame(names = c("batch_header_1", 14 | "batch_header_2", 15 | "batch_header_3", 16 | "batch_header_new", 17 | "administrative_segment", 18 | "offense_segment", 19 | "property_segment", 20 | "victim_segment", 21 | "offender_segment", 22 | "arrestee_segment", 23 | "group_b_arrest_report_segment", 24 | "window_exceptional_clearance_segment", 25 | "window_recovered_property_segment", 26 | "window_arrestee_segment"), 27 | levels = c("B1", 28 | "B2", 29 | "B3", 30 | "BH", 31 | "01", 32 | "02", 33 | "03", 34 | "04", 35 | "05", 36 | "06", 37 | "07", 38 | "W1", 39 | "W3", 40 | "W6")) 41 | segment_levels 42 | 43 | for (n in 1:nrow(files)) { 44 | setwd("D:/ucr_data_storage/raw_data/nibrs_from_fbi") 45 | print(files$file[n]) 46 | data <- read_lines(files$file[n]) 47 | # data <- data.table::fread(files$file[n], sep = NULL, header = FALSE, strip.white = FALSE) 48 | # data <- data$V1 49 | head(data) 50 | length(data) 51 | print(table(substr(data, 1, 2))) 52 | 53 | for (i in 1:nrow(segment_levels)) { 54 | temp <- data[substr(data, 1, 2) %in% segment_levels$levels[i]] 55 | if (length(temp) > 0) { 56 | setwd("D:/ucr_data_storage/raw_data/nibrs_master_files_parsed") 57 | write_lines(temp, file = paste0(segment_levels$names[i], 58 | "_", files$year[n], ".txt")) 59 | } 60 | rm(temp); gc(); message(segment_levels$names[i]) 61 | } 62 | rm(data); gc(); Sys.sleep(2) 63 | message(files$file[n]) 64 | } 65 | -------------------------------------------------------------------------------- /R/utils-pipe.R: -------------------------------------------------------------------------------- 1 | #' Pipe operator 2 | #' 3 | #' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @export 9 | #' @importFrom magrittr %>% 10 | #' @usage lhs \%>\% rhs 11 | NULL 12 | -------------------------------------------------------------------------------- /R/utils/arrests_utils_objects.R: -------------------------------------------------------------------------------- 1 | matches_types <- data.frame(matches = 2 | c(# Age by sex 3 | "(fe)?male|tot_arrest|tot_juv|tot_adult|tot_.*[0-9]", 4 | #"Totals race, sex" 5 | "black|white|asian|ind|tot_arrest|hisp|tot_(fe)?male|tot_arrest|tot_juv|tot_adult"), 6 | name = c("age", 7 | "race_sex")) 8 | 9 | index_crimes <- c("murder", 10 | "rape", 11 | "robbery", 12 | "agg_assault", 13 | "burglary", 14 | "theft", 15 | "mtr_veh_theft", 16 | "arson") 17 | 18 | 19 | drug_crimes <- c("total_drug", 20 | "sale_drug_total", 21 | "sale_cannabis", 22 | "sale_heroin_coke", 23 | "sale_other_drug", 24 | "sale_synth_narc", 25 | "poss_drug_total", 26 | "poss_cannabis", 27 | "poss_heroin_coke", 28 | "poss_other_drug", 29 | "poss_synth_narc") 30 | 31 | alcohol_or_property_crimes <- c("forgery", 32 | "fraud", 33 | "stolen_prop", 34 | "dui", 35 | "liquor", 36 | "drunkenness", 37 | "embezzlement", 38 | "gamble_total", 39 | "gamble_other", 40 | "gamble_bookmake", 41 | "gamble_lottery") 42 | 43 | other_crimes <- c("vandalism", 44 | "disorder_cond", 45 | "all_other", 46 | "curfew_loiter", 47 | "vagrancy", 48 | "runaways", 49 | "suspicion", 50 | "prostitution", 51 | "oth_sex_off", 52 | "family_off", 53 | "oth_assault", 54 | "weapons", 55 | "manslaught_neg") 56 | 57 | all_crimes <- unique(c(index_crimes, 58 | alcohol_or_property_crimes, 59 | drug_crimes, 60 | other_crimes)) 61 | 62 | combined_crimes <- list(index_crimes, 63 | alcohol_or_property_crimes, 64 | drug_crimes, 65 | other_crimes, 66 | all_crimes) 67 | 68 | names(combined_crimes) <- c("index_crimes", 69 | "alcohol_or_property_crimes", 70 | "drug_crimes", 71 | "other_crimes", 72 | "all_crimes") 73 | 74 | arrest_cols <- c("adult_amer_ind", 75 | "adult_asian", 76 | "adult_black", 77 | "adult_white", 78 | "adult_hispanic", 79 | "adult_non_hisp", 80 | "juv_amer_ind", 81 | "juv_asian", 82 | "juv_black", 83 | "juv_white", 84 | "juv_hispanic", 85 | "juv_non_hisp", 86 | "female_under_10", 87 | "female_10_12", 88 | "female_13_14", 89 | "female_15", 90 | "female_16", 91 | "female_17", 92 | "female_18", 93 | "female_19", 94 | "female_20", 95 | "female_21", 96 | "female_22", 97 | "female_23", 98 | "female_24", 99 | "female_25_29", 100 | "female_30_34", 101 | "female_35_39", 102 | "female_40_44", 103 | "female_45_49", 104 | "female_50_54", 105 | "female_55_59", 106 | "female_60_64", 107 | "female_over_64", 108 | "male_under_10", 109 | "male_10_12", 110 | "male_13_14", 111 | "male_15", 112 | "male_16", 113 | "male_17", 114 | "male_18", 115 | "male_19", 116 | "male_20", 117 | "male_21", 118 | "male_22", 119 | "male_23", 120 | "male_24", 121 | "male_25_29", 122 | "male_30_34", 123 | "male_35_39", 124 | "male_40_44", 125 | "male_45_49", 126 | "male_50_54", 127 | "male_55_59", 128 | "male_60_64", 129 | "male_over_64") 130 | 131 | arrest_cols_1974 <- c(arrest_cols, 132 | "male_under_11", 133 | "female_under_11", 134 | "male_11_12", 135 | "female_11_12", 136 | "adult_chinese", 137 | "adult_japanese", 138 | "juv_chinese", 139 | "juv_japanese", 140 | "female_adult_unknown_age", 141 | "female_juvenile_unknown_age", 142 | "male_adult_unknown_age", 143 | "male_juvenile_unknown_age") -------------------------------------------------------------------------------- /R/utils/hate_crime_utils.R: -------------------------------------------------------------------------------- 1 | misc_cols <- c("population_group", 2 | "country_division", 3 | "country_region", 4 | "core_city", 5 | "covered_by_ori", 6 | "fbi_field_office", 7 | "judicial_district", 8 | "agency_nibrs_flag", 9 | "agency_inactive_date", 10 | "date_ori_was_added", 11 | "date_ori_went_nibrs", 12 | "state_first_quarter_activity", 13 | "state_second_quarter_activity", 14 | "state_third_quarter_activity", 15 | "state_fourth_quarter_activity", 16 | "federal_first_quarter_activity", 17 | "federal_second_quarter_activity", 18 | "federal_third_quarter_activity", 19 | "federal_fourth_quarter_activity", 20 | "data_source", 21 | "quarter_of_the_year", 22 | "agency_indicator") 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /R/utils/leoka_utils.R: -------------------------------------------------------------------------------- 1 | make_number_of_months_reporting <- function(data) { 2 | month_indicators <- grep("month_indicator", names(data), value = TRUE) 3 | 4 | data$number_of_months_reported <- 0 5 | 6 | # Years 1960-1971 all have jan_month_indicator as 'not reported' 7 | # which seems incorrect. I am setting the number_of_months_reported 8 | # for these years to 1 to fix this issue. All months other than 9 | # January seem normal. 10 | if (fix_years(data$year)[1] %in% 1960:1971) { 11 | data$number_of_months_reported <- 1 12 | } 13 | # 14 | # 15 | # Months that are 'reported, no data' are considered to be non-reports!!!!!! 16 | for (col in month_indicators) { 17 | adder <- rep(0, nrow(data)) 18 | adder[data[, col] %in% c("normal update", "reported, no data")] <- 1 19 | data$number_of_months_reported <- data$number_of_months_reported + adder 20 | 21 | # The record description says all years before 1971 have no 22 | # month indicator info but that's not true in the data. 23 | # if (data$year[1] < 1971) { 24 | # data$number_of_months_reported <- NA 25 | # } 26 | 27 | } 28 | 29 | # If year 1960-1971 and only month is one I added, turn it to 0 30 | if (fix_years(data$year)[1] %in% 1960:1971) { 31 | data$number_of_months_reported[data$number_of_months_reported == 1] <- 0 32 | } 33 | 34 | return(data) 35 | } 36 | 37 | 38 | reorder_leoka_columns <- function(data, crosswalk, type = "month") { 39 | time_cols <- c("year", 40 | "month", 41 | "date") 42 | 43 | if (type == "year") { 44 | time_cols <- "year" 45 | } 46 | crosswalk_cols <- names(crosswalk) 47 | 48 | # Reorder columns 49 | # Also merge with crosswalk data 50 | data <- 51 | data %>% 52 | dplyr::select(ori, 53 | agency_name, 54 | state, 55 | state_abb, 56 | number_of_months_reported, 57 | time_cols, 58 | crosswalk_cols, 59 | population, 60 | population_group, 61 | country_division, 62 | msa, 63 | report_indicator, 64 | record_indicator, 65 | month_indicator, 66 | covered_by, 67 | shift_data, 68 | no_male_female_breakdown, 69 | assault_injury_indicator, 70 | assault_no_injury_indicator, 71 | ends_with("officers"), 72 | total_employees_officers, 73 | ends_with("civilians"), 74 | total_employees_civilians, 75 | ends_with("employees_total"), 76 | total_employees_total, 77 | officers_killed_total, 78 | officers_killed_by_felony, 79 | officers_killed_by_accident, 80 | starts_with("assaults_with_injury"), 81 | starts_with("assaults_no_injury"), 82 | starts_with("ambush"), 83 | starts_with("oth_arr"), 84 | starts_with("burglary"), 85 | starts_with("derang"), 86 | starts_with("disturban"), 87 | starts_with("prisoner"), 88 | starts_with("riot"), 89 | starts_with("robbery"), 90 | starts_with("susp"), 91 | starts_with("traffic"), 92 | starts_with("all_other"), 93 | total_names, 94 | starts_with("time"), 95 | ends_with("shift"), 96 | everything()) 97 | if (type == "month") { 98 | data <- 99 | data %>% 100 | dplyr::mutate(month = factor(month, 101 | levels = tolower(month.name))) %>% 102 | dplyr::arrange(ori, 103 | month) %>% 104 | dplyr::mutate(month = as.character(month)) 105 | } 106 | 107 | return(data) 108 | } 109 | 110 | 111 | fix_outliers <- function(data) { 112 | if (data$year[1] == 1977) { 113 | data$oct_officers_killed_by_accident[data$ori %in% "KS08703"] <- NA 114 | } 115 | if (data$year[1] == 1978) { 116 | data$jul_officers_killed_by_accident[data$ori %in% "PAPPD00"] <- NA 117 | } 118 | if (data$year[1] == 1979) { 119 | data$aug_officers_killed_by_felony[data$ori %in% "NJ01210"] <- NA 120 | } 121 | if (data$year[1] == 1979) { 122 | data$dec_officers_killed_by_felony[data$ori %in% "WASPD00"] <- NA 123 | } 124 | if (data$year[1] == 1980) { 125 | data$aug_officers_killed_by_felony[data$ori %in% "LA02600"] <- NA 126 | } 127 | if (data$year[1] == 1982) { 128 | data$nov_officers_killed_by_felony[data$ori %in% "CA03801"] <- NA 129 | } 130 | if (data$year[1] == 1990) { 131 | data$mar_officers_killed_by_accident[data$ori %in% "ME010SP"] <- NA 132 | } 133 | if (data$year[1] == 1996) { 134 | data$sep_officers_killed_by_felony[data$ori %in% "LA03102"] <- NA 135 | } 136 | if (data$year[1] == 1997) { 137 | data$mar_officers_killed_by_felony[data$ori %in% "MO0950E"] <- NA 138 | } 139 | if (data$year[1] == 2011) { 140 | data[data$ori %in% "OR02405", grep("employee", names(data))] <- NA 141 | } 142 | if (data$year[1] == 2014) { 143 | data <- data[!data$ori %in% "NDDI019", ] 144 | } 145 | if (data$year[1] == 2017) { 146 | data$jan_officers_killed_by_accident[data$ori %in% "IN08200"] <- NA 147 | 148 | } 149 | 150 | # This agency has wrong state and is only there for first 5 years. 151 | data <- data[!data$ori %in% "OKDI001", ] 152 | 153 | 154 | return(data) 155 | } 156 | 157 | -------------------------------------------------------------------------------- /R/utils/offenses_known_utils.R: -------------------------------------------------------------------------------- 1 | make_agg_assault <- function(data) { 2 | crime_type <- c("actual", "clr_18", "tot_clr", "unfound") 3 | 4 | for (type in crime_type) { 5 | 6 | # For some reason the total assault variable during 7 | # 1964-1973 does NOT include simple assault but 8 | # in other years it does. So this fixes that. 9 | if (data$year[1] %in% 1964:1973) { 10 | data[, paste0( type, "_assault_total")] <- 11 | data[, paste0(type, "_assault_total")] + 12 | data[, paste0(type, "_assault_simple")] 13 | } 14 | 15 | data[, paste0(type, "_assault_aggravated")] <- 16 | data[, paste0(type, "_assault_total")] - 17 | data[, paste0(type, "_assault_simple")] 18 | 19 | # Some agencies that don't report aggravated assault 20 | # crimes properly will have very large negative numbers 21 | # of aggravated assault. This makes all aggravated assault 22 | # under -25 to become NA. 23 | data[data[paste0(type, "_assault_aggravated")] < -25 | 24 | is.na(data[paste0(type, "_assault_aggravated")]), 25 | paste0(type, "_assault_aggravated")] <- NA 26 | } 27 | return(data) 28 | } 29 | make_index_crimes <- function(data) { 30 | crime_type <- c("actual", "clr_18", "tot_clr", "unfound") 31 | #index_crimes <- c("index_violent", "index_property", "index_total") 32 | 33 | for (type in crime_type) { 34 | data[, paste0(type, "_index_violent")] <- 35 | data[, paste0(type, "_murder")] + 36 | data[, paste0(type, "_rape_total")] + 37 | data[, paste0(type, "_assault_aggravated")] + 38 | data[, paste0(type, "_robbery_total")] 39 | 40 | if (data$year[1] >= 1979) { 41 | 42 | data[, paste0(type, "_index_property")] <- 43 | data[, paste0(type, "_theft_total")] + 44 | data[, paste0(type, "_burg_total")] + 45 | data[, paste0(type, "_mtr_veh_theft_total")] + 46 | data[, paste0(type, "_arson_grand_total")] 47 | } else { 48 | data[, paste0(type, "_index_property")] <- 49 | data[, paste0(type, "_theft_total")] + 50 | data[, paste0(type, "_burg_total")] + 51 | data[, paste0(type, "_mtr_veh_theft_total")] 52 | } 53 | 54 | data[, paste0(type, "_index_total")] <- 55 | data[, paste0(type, "_index_violent")] + 56 | data[, paste0(type, "_index_property")] 57 | } 58 | return(data) 59 | } 60 | 61 | 62 | 63 | fix_outliers <- function(data) { 64 | 65 | data$population[data$population > 200000000] <- NA 66 | # Incorrect ORI 67 | if (data$year[1] == 1972) { 68 | data$ori[data$state %in% "virginia" & 69 | data$population_1 %in% "446963"] <- "VA02901" 70 | } 71 | 72 | 73 | # Impossibly high number of unfounded crimes in New Orleans in 2018 74 | # Incorrect ORI 75 | if (data$year[1] == 2018) { 76 | data[data$ori %in% "LANPD00", grep("unfound", names(data))] <- NA 77 | } 78 | 79 | # Incorrect ORI 80 | data <- data[!data$ori %in% "OKDI001",] 81 | 82 | # Impossible numbers of officers killed. 83 | if (data$year[1] == 1974) { 84 | data$nov_officers_killed_by_accident[data$ori %in% "MA01301"] <- NA 85 | } 86 | if (data$year[1] == 1978) { 87 | data$mar_officers_killed_by_accident[data$ori %in% "PAPPD00"] <- NA 88 | data$apr_officers_killed_by_accident[data$ori %in% "NY06240"] <- NA 89 | data$jun_officers_killed_by_accident[data$ori %in% "NY06240"] <- NA 90 | data$may_officers_killed_by_accident[data$ori %in% "NY04040"] <- NA 91 | 92 | data$apr_officers_killed_by_felony[data$ori %in% "NY06240"] <- NA 93 | data$jun_officers_killed_by_felony[data$ori %in% "NY06240"] <- NA 94 | data$may_officers_killed_by_felony[data$ori %in% "NY04040"] <- NA 95 | } 96 | if (data$year[1] == 1996) { 97 | data$sep_officers_killed_by_felony[data$ori %in% "LA03102"] <- NA 98 | } 99 | if (data$year[1] == 1997) { 100 | data$mar_officers_killed_by_felony[data$ori %in% "MO0950E"] <- NA 101 | } 102 | if (data$year[1] %in% 2014:2016) { 103 | data[data$ori %in% "LANPD00", grep("unfound_", names(data))] <- NA 104 | } 105 | return(data) 106 | } 107 | 108 | 109 | 110 | crime_remove_special_characters <- function(col) { 111 | col <- iconv(col, "UTF-8", "ASCII", sub = "") 112 | col <- gsub(" conty, ", " county, ", col, ignore.case = TRUE) 113 | return(col) 114 | } 115 | -------------------------------------------------------------------------------- /R/utils/saving_utils.R: -------------------------------------------------------------------------------- 1 | library(haven) 2 | save_files <- function(data, 3 | year, 4 | file_name, 5 | save_name, 6 | rds_only = FALSE) { 7 | if (any(nchar(names(data)) > 31)) { 8 | print(names(data)[nchar(names(data)) > 31]) 9 | } 10 | 11 | data <- 12 | data %>% 13 | dplyr::mutate_if(is.Date, as.character) 14 | data <- ungroup(data) 15 | data <- as.data.frame(data) 16 | 17 | 18 | saveRDS(data, file = paste0(save_name, year, ".rds")) 19 | if (!rds_only) { 20 | write_dta(data, path = paste0(save_name, year, ".dta")) 21 | } 22 | } 23 | 24 | save_as_zip <- function(file_name, pattern = NULL) { 25 | file_ext <- c("rds", "dta") 26 | all_files <- list.files() 27 | 28 | 29 | all_file_extentions <- gsub(".*\\.", "", all_files) 30 | file_ext <- file_ext[file_ext %in% unique(all_file_extentions)] 31 | if (!is.null(pattern)) { 32 | sps_files <- all_files[grep("maltz|manual|sps$|record description", 33 | all_files, ignore.case = TRUE)] 34 | all_files <- list.files(pattern = pattern) 35 | all_files <- c(sps_files, all_files) 36 | } 37 | 38 | if (any(grepl(".zip$", all_files))) { 39 | all_files <- all_files[-grep(".zip$", all_files)] 40 | } 41 | 42 | codebooks <- list.files(pattern = "maltz|manual|codebook|pdf$|sps$|doc$|docx$|txt$") 43 | for (i in seq_along(file_ext)) { 44 | zip_files <- all_files[grep(file_ext[i], all_files)] 45 | zip_files <- c(zip_files, codebooks) 46 | zip_files <- sort(zip_files) 47 | 48 | zip::zipr(zipfile = paste0(file_name, 49 | file_ext[i], ".zip"), 50 | files = zip_files) 51 | } 52 | } 53 | 54 | save_raw_as_zip <- function(file_name) { 55 | all_files <- list.files() 56 | zip::zip(zipfile = paste0(file_name, ".zip"), 57 | files = all_files) 58 | } 59 | -------------------------------------------------------------------------------- /R/utils/supplement_utils.R: -------------------------------------------------------------------------------- 1 | supplement_remove_missing <- function(column) { 2 | column[column %in% c(1000, 3 | 2000, 4 | 3000, 5 | 4000, 6 | 5000, 7 | 6000, 8 | 7000, 9 | 8000, 10 | 9000, 11 | 10000, 12 | 20000, 13 | 30000, 14 | 40000, 15 | 50000, 16 | 60000, 17 | 70000, 18 | 80000, 19 | 90000, 20 | 100000, 21 | 99942)] <- NA 22 | return(column) 23 | } 24 | 25 | make_num_months_reported <- function(data) { 26 | status_cols <- grep("status", names(data), value = TRUE) 27 | 28 | data$number_of_months_reported <- 0 29 | for (col in status_cols) { 30 | # Some old years (1966-1973) have a 2 option which seems to 31 | # be they report offenses but not value. 32 | value <- data[, col] 33 | value[value %in% "not reported"] <- 0 34 | value[value %in% c("regular", 2)] <- 1 35 | value <- as.numeric(value) 36 | 37 | data$number_of_months_reported <- data$number_of_months_reported + value 38 | } 39 | return(data) 40 | } 41 | 42 | agency_desc_cols <- c( 43 | "ori9", 44 | "number_of_months_reported", 45 | "census_name", 46 | "crosswalk_agency_name", 47 | "state", 48 | "agency_name", 49 | "year", 50 | "population", 51 | "population_group", 52 | "country_division", 53 | "msa", 54 | "report_indicator", 55 | "fbi_batch_number", 56 | "fips_state_code", 57 | "fips_county_code", 58 | "fips_state_county_code", 59 | "fips_place_code", 60 | "agency_type", 61 | "longitude", 62 | "latitude", 63 | "address_name", 64 | "address_street_line_1", 65 | "address_street_line_2", 66 | "address_city", 67 | "address_state", 68 | "address_zip_code" 69 | ) 70 | 71 | offense_col_order <- c( 72 | "offenses_burg_resident_day", 73 | "offenses_burg_resident_night", 74 | "offenses_burg_resident_unk", 75 | "offenses_burg_nonresident_day", 76 | "offenses_burg_nonresident_night", 77 | "offenses_burg_nonresident_unk", 78 | "offenses_burg_total", 79 | 80 | "offenses_motor_vehicle_theft", 81 | "offenses_murder", 82 | "offenses_rape", 83 | 84 | "offenses_robbery_bank", 85 | "offenses_robbery_chain_store", 86 | "offenses_robbery_gas_station", 87 | "offenses_robbery_highway", 88 | "offenses_robbery_house", 89 | "offenses_robbery_misc", 90 | "offenses_robbery_residence", 91 | "offenses_robbery_total", 92 | 93 | "offenses_theft_under_50", 94 | "offenses_theft_50_to_200", 95 | "offenses_theft_over_200", 96 | "offenses_theft_total", 97 | "offenses_theft_auto_part", 98 | "offenses_theft_bicycle", 99 | "offenses_theft_coin_machine", 100 | "offenses_theft_from_auto", 101 | "offenses_theft_from_building", 102 | "offenses_theft_pick_pocket", 103 | "offenses_theft_purse_snatch", 104 | "offenses_theft_shoplift", 105 | "offenses_theft_all_other", 106 | 107 | "auto_stolen_recover_local", 108 | "auto_stolen_recovered_other", 109 | "auto_theft_total", 110 | "auto_stole_oth_recover_local" 111 | ) 112 | 113 | value_col_order <- c( 114 | "value_burg_resident_night", 115 | "value_burg_resident_day", 116 | "value_burg_resident_unk", 117 | "value_burg_nonresident_night", 118 | "value_burg_nonresident_day", 119 | "value_burg_nonresident_unk", 120 | "value_burg_total", 121 | 122 | "value_motor_vehicle_theft", 123 | "value_murder", 124 | "value_rape", 125 | 126 | "value_robbery_bank", 127 | "value_robbery_chain_store", 128 | "value_robbery_gas_station", 129 | "value_robbery_highway", 130 | "value_robbery_house", 131 | "value_robbery_misc", 132 | "value_robbery_residence", 133 | "value_robbery_total", 134 | 135 | "value_theft_under_50", 136 | "value_theft_50_to_200", 137 | "value_theft_over_200", 138 | "value_theft_total", 139 | 140 | # Is total value for all above categories 141 | "value_total_all_values", 142 | 143 | # Not included in value_total_all_values 144 | "value_theft_auto_part", 145 | "value_theft_bicycle", 146 | "value_theft_coin_machine", 147 | "value_theft_from_auto", 148 | "value_theft_from_building", 149 | "value_theft_pick_pocket", 150 | "value_theft_purse_snatch", 151 | "value_theft_shoplift", 152 | "value_theft_all_other", 153 | 154 | "value_stolen_clothing_or_fur", 155 | "value_stolen_consumable_good", 156 | "value_stolen_currency", 157 | "value_stolen_guns", 158 | "value_stolen_household_good", 159 | "value_stolen_jewel_metal", 160 | "value_stolen_livestock", 161 | "value_stolen_local_mtr_veh", 162 | "value_stolen_misc", 163 | "value_stolen_office_equip", 164 | "value_stolen_tv_and_radio", 165 | "value_stolen_total", 166 | 167 | "value_recovered_clothing_or_fur", 168 | "value_recovered_consumable_good", 169 | "value_recovered_currency", 170 | "value_recovered_guns", 171 | "value_recovered_house_good", 172 | "value_recovered_jewel_metal", 173 | "value_recovered_livestock", 174 | "value_recovered_local_mtv_veh", 175 | "value_recovered_misc", 176 | "value_recovered_office_equip", 177 | "value_recovered_tv_and_radio", 178 | "value_recovered_total" 179 | ) 180 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a long-term project to collect and clean crime data (primarily FBI crime data) and make it accessible to the public. The code here is mostly to read in the data from the FBI raw files, clean it slightly, and combine years together for a single file. -------------------------------------------------------------------------------- /compress_stata_files.do: -------------------------------------------------------------------------------- 1 | 2 | 3 | // For manually selected folder 4 | 5 | local filelist: dir . files "*.dta" 6 | di `filelist' 7 | foreach file of local filelist { 8 | use "`file'", clear 9 | compress 10 | save, replace 11 | } 12 | -------------------------------------------------------------------------------- /crime_data.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | StripTrailingWhitespace: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | -------------------------------------------------------------------------------- /crosswalk.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/crosswalk.rds -------------------------------------------------------------------------------- /fbi_record_descriptions/ASR Records Description updated summarized.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/ASR Records Description updated summarized.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/Arson Record Description.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Arson Record Description.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/Arson Records Description updated.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Arson Records Description updated.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/Cargo Theft Technical Specification1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Cargo Theft Technical Specification1.docx -------------------------------------------------------------------------------- /fbi_record_descriptions/HCrecorddescrip.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/HCrecorddescrip.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/Hate Crime Technical Specification v.1.2 6-29-18.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Hate Crime Technical Specification v.1.2 6-29-18.docx -------------------------------------------------------------------------------- /fbi_record_descriptions/NIBRS Record Description.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/NIBRS Record Description.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/NIBRS Records Description updated.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/NIBRS Records Description updated.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/Police Employee - LEOKA Records Description updated.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Police Employee - LEOKA Records Description updated.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/Police Employee Record Description.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Police Employee Record Description.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/Record Description.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Record Description.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/Return A Record Description.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Return A Record Description.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/Return A Records Description updated.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Return A Records Description updated.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/SHRYR current Record Layout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/SHRYR current Record Layout.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/Summary Reporting Technical Specification.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Summary Reporting Technical Specification.docx -------------------------------------------------------------------------------- /fbi_record_descriptions/Supplement to Return A Records Description updated.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Supplement to Return A Records Description updated.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/Supplementary Homicide Report Records Description updated.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/Supplementary Homicide Report Records Description updated.xlsx -------------------------------------------------------------------------------- /fbi_record_descriptions/asr_month_1974_1979.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/asr_month_1974_1979.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/asr_month_1980_present.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/asr_month_1980_present.pdf -------------------------------------------------------------------------------- /fbi_record_descriptions/cargo_theft.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/cargo_theft.docx -------------------------------------------------------------------------------- /fbi_record_descriptions/human-trafficking-help.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/human-trafficking-help.docx -------------------------------------------------------------------------------- /fbi_record_descriptions/retarecdesc.wpd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/retarecdesc.wpd -------------------------------------------------------------------------------- /fbi_record_descriptions/supprecdes.wpd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/supprecdes.wpd -------------------------------------------------------------------------------- /fbi_record_descriptions/supprecdes.wpd.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/fbi_record_descriptions/supprecdes.wpd.pdf -------------------------------------------------------------------------------- /final_washpost_ucr_merged.dta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/final_washpost_ucr_merged.dta -------------------------------------------------------------------------------- /inst/testdata/alexander_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Alexander City Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 14558, 110, 0, 5,, 6, 99, 654, 156, 465, 33 12 | 1986,10, 14130, 104, 3, 5,, 7, 89, 508, 97, 388, 23 13 | 1987,6, 14116, 53, 0, 0,, 2, 51, 257, 72, 175, 10 14 | 1988,12, 14379, 114, 2, 8,, 8, 96, 561, 113, 432, 16 15 | 1989,12, 14508, 150, 2, 10,, 7, 131, 702, 148, 527, 27 16 | 1990,12, 14917, 117, 6, 3,, 10, 98, 624, 166, 444, 14 17 | 1991,12, 15095, 165, 4, 2,, 16, 143, 648, 142, 490, 16 18 | 1992,12, 15268, 63, 1, 1,, 16, 45, 280, 99, 170, 11 19 | 1993,12, 15218, 52, 4, 1,, 11, 36, 137, 56, 77, 4 20 | 1994,12, 15334, 180, 3, 8,, 32, 137, 877, 138, 719, 20 21 | 1995,12, 15216, 104, 5, 6,, 33, 60, 883, 155, 701, 27 22 | 1996,12, 15287, 94, 0, 3,, 23, 68, 917, 178, 719, 20 23 | 1997,12, 15451, 118, 1, 6,, 22, 89, 989, 170, 790, 29 24 | 1998,12, 15792, 69, 0, 4,, 25, 40, 831, 139, 670, 22 25 | 1999,12, 16090, 76, 3, 4,, 11, 58, 736, 121, 596, 19 26 | 2000,12, 15008, 73, 3, 8,, 15, 47, 797, 119, 658, 20 27 | 2001,12, 15066, 88, 0, 10,, 5, 73, 977, 140, 815, 22 28 | 2002,12, 15141, 114, 2, 8,, 23, 81, 873, 129, 724, 20 29 | 2003,12, 14879, 108, 0, 4,, 17, 87, 811, 136, 663, 12 30 | 2004,12, 15064, 130, 0, 5,, 20, 105, 952, 168, 761, 23 31 | 2005,12, 15062, 142, 1, 8,, 21, 112, 859, 190, 643, 26 32 | 2007,12, 15053, 131, 2, 14,, 24, 91, 1016, 182, 784, 50 33 | 2008,12, 14917, 204, 3, 14,, 47, 140, 1024, 190, 790, 44 34 | 2009,12, 15057, 132, 2, 10,, 31, 89, 843, 180, 631, 32 35 | 2010,12, 14875, 59, 1, 8,, 9, 41, 646, 113, 522, 11 36 | 2011,12, 14947, 138, 0, 12,, 11, 115, 768, 206, 527, 35 37 | 2012,12, 14936, 95, 2, 2,, 15, 76, 688, 125, 536, 27 38 | 2013,12, 14692, 119, 2,, 16, 12, 89, 661, 121, 510, 30 39 | 2014,12, 14887, 81, 1,, 8, 8, 64, 716, 165, 523, 28 40 | 41 | 42 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 43 | 44 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 45 | 46 | 47 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 48 | 49 | 50 | 51 | Crime rates are not available for agencies that report data for less than 12 months of a year. 52 | 53 | 54 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 55 | Date of download: Nov 20 2018 -------------------------------------------------------------------------------- /inst/testdata/birmingham_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Birmingham Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 281973, 3350, 97, 283,, 1435, 1535, 24726, 7173, 14042, 3511 12 | 1986,12, 286756, 3769, 88, 325,, 1583, 1773, 24697, 7784, 13405, 3508 13 | 1987,12, 282171, 3532, 84, 311,, 1591, 1546, 24264, 7250, 13726, 3288 14 | 1988,12, 283237, 3419, 92, 246,, 1292, 1789, 22978, 6783, 13235, 2960 15 | 1989,12, 278011, 4020, 100, 258,, 1766, 1896, 22328, 6529, 12100, 3699 16 | 1990,12, 265968, 4193, 125, 267,, 1799, 2002, 25759, 6958, 13728, 5073 17 | 1991,12, 269313, 6908, 139, 279,, 1861, 4629, 26987, 7894, 14869, 4224 18 | 1992,12, 272407, 6144, 133, 362,, 1854, 3795, 26409, 7447, 15231, 3731 19 | 1993,12, 268768, 6678, 121, 297,, 1706, 4554, 25098, 6628, 14926, 3544 20 | 1994,12, 270978, 6625, 135, 273,, 1980, 4237, 26412, 6483, 16285, 3644 21 | 1995,12, 270728, 6649, 121, 248,, 2158, 4122, 26388, 6399, 16309, 3680 22 | 1996,12, 272169, 4416, 113, 229,, 1838, 2236, 24867, 5973, 15280, 3614 23 | 1997,12, 275236, 3785, 108, 222,, 1337, 2118, 22610, 5186, 14067, 3357 24 | 1998,12, 259453, 3147, 85, 206,, 969, 1887, 19386, 4130, 12613, 2643 25 | 1999,12, 254171, 2843, 78, 212,, 939, 1614, 17867, 3855, 12035, 1977 26 | 2000,12, 242820, 2947, 79, 228,, 977, 1663, 17802, 4078, 11975, 1749 27 | 2001,12, 243762, 3027, 73, 206,, 1084, 1664, 18058, 4079, 11928, 2051 28 | 2002,12, 244972, 3187, 65, 239,, 1186, 1697, 18078, 4389, 11640, 2049 29 | 2003,12, 240176, 3347, 85, 204,, 1352, 1706, 19574, 4831, 11934, 2809 30 | 2004,12, 238167, 3261, 59, 240,, 1369, 1593, 19477, 5156, 11970, 2351 31 | 2005,12, 234571, 3449, 104, 241,, 1429, 1675, 18923, 4933, 11962, 2028 32 | 2006,12, 233577, 3175, 104, 220,, 1429, 1422, 19007, 4813, 12113, 2081 33 | 2007,12, 227686, 3320, 86, 229,, 1609, 1396, 19638, 4864, 12528, 2246 34 | 2008,12, 228314, 3249, 82, 212,, 1499, 1456, 20054, 5153, 12761, 2140 35 | 2009,12, 227373, 2812, 65, 198,, 1150, 1399, 18159, 5019, 11546, 1594 36 | 2010,6, 212237, 1343, 20, 81,, 416, 826, 8637, 2608, 5299, 730 37 | 2011,12, 213258, 3163, 54, 182,, 1011, 1916, 17841, 5806, 10522, 1513 38 | 2012,12, 213266, 3237, 67, 152,, 983, 2035, 14788, 4704, 9042, 1042 39 | 2013,12, 212001, 2852, 63,, 178, 969, 1642, 14157, 4018, 8661, 1478 40 | 2014,12, 212115, 3369, 52,, 182, 1051, 2084, 13929, 3750, 8743, 1436 41 | 42 | 43 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 44 | 45 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 46 | 47 | 48 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 49 | 50 | 51 | 52 | Crime rates are not available for agencies that report data for less than 12 months of a year. 53 | 54 | 55 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 56 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /inst/testdata/fairfield_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Fairfield Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 13192, 140, 1, 5,, 56, 78, 1018, 222, 642, 154 12 | 1986,12, 13142, 189, 2, 11,, 65, 111, 1123, 213, 772, 138 13 | 1987,12, 12978, 165, 0, 9,, 66, 90, 1046, 261, 677, 108 14 | 1988,12, 13027, 209, 3, 10,, 75, 121, 1036, 238, 662, 136 15 | 1989,12, 12842, 258, 2, 13,, 113, 130, 1297, 252, 827, 218 16 | 1990,12, 12200, 266, 2, 7,, 110, 147, 1504, 350, 905, 249 17 | 1991,12, 12346, 278, 1, 5,, 119, 153, 1782, 344, 1135, 303 18 | 1992,12, 12487, 250, 3, 12,, 108, 127, 1625, 254, 1116, 255 19 | 1993,12, 12402, 242, 3, 11,, 79, 149, 1106, 199, 716, 191 20 | 1994,12, 12496, 236, 2, 9,, 108, 117, 1557, 316, 1027, 214 21 | 1995,12, 12486, 199, 2, 5,, 79, 113, 1517, 260, 1140, 117 22 | 1996,12, 12544, 182, 0, 9,, 78, 95, 1660, 284, 1209, 167 23 | 1997,12, 12679, 164, 0, 3,, 72, 89, 1533, 156, 1215, 162 24 | 1998,12, 11537, 166, 2, 6,, 68, 90, 1400, 171, 1105, 124 25 | 1999,12, 11229, 111, 0, 7,, 66, 38, 1395, 211, 1082, 102 26 | 2001,12, 12429, 156, 12, 3,, 83, 58, 1603, 249, 1160, 194 27 | 2002,12, 12491, 126, 0, 6,, 68, 52, 1604, 209, 1155, 240 28 | 2003,12, 12106, 118, 5, 9,, 74, 30, 1643, 252, 1210, 181 29 | 2004,12, 11996, 123, 0, 14,, 58, 51, 1667, 314, 1236, 117 30 | 2005,12, 11938, 135, 4, 6,, 83, 42, 1121, 236, 794, 91 31 | 2006,12, 11802, 98, 1, 3,, 46, 48, 792, 170, 528, 94 32 | 2007,12, 11443, 209, 4, 12,, 84, 109, 1212, 238, 877, 97 33 | 2008,12, 11303, 187, 3, 9,, 99, 76, 1464, 408, 912, 144 34 | 2009,12, 11212, 102, 0, 5,, 50, 47, 1229, 373, 771, 85 35 | 2010,12, 11117, 105, 4, 5,, 36, 60, 1352, 396, 869, 87 36 | 2011,12, 11171, 191, 4, 9,, 82, 96, 1296, 446, 752, 98 37 | 2012,12, 11169, 153, 2, 7,, 61, 83, 1337, 462, 800, 75 38 | 2013,12, 11003, 181, 4,, 12, 67, 98, 1007, 284, 650, 73 39 | 2014,10, 10913, 119, 3,, 7, 49, 60, 790, 219, 521, 50 40 | 41 | 42 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 43 | 44 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 45 | 46 | 47 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 48 | 49 | 50 | 51 | Crime rates are not available for agencies that report data for less than 12 months of a year. 52 | 53 | 54 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 55 | Date of download: Nov 21 2018 -------------------------------------------------------------------------------- /inst/testdata/fort_payne_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Fort Payne Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 12103, 35, 0, 1,, 9, 25, 557, 121, 408, 28 12 | 1986,12, 12220, 40, 2, 1,, 4, 33, 467, 78, 359, 30 13 | 1987,12, 11829, 37, 0, 4,, 8, 25, 465, 75, 349, 41 14 | 1988,12, 12020, 71, 0, 3,, 6, 62, 462, 100, 326, 36 15 | 1989,11, 11819, 59, 4, 0,, 4, 51, 588, 93, 461, 34 16 | 1990,12, 11838, 31, 1, 0,, 6, 24, 572, 116, 415, 41 17 | 1991,12, 11979, 15, 0, 0,, 4, 11, 343, 72, 251, 20 18 | 1992,12, 12116, 10, 0, 0,, 3, 7, 275, 49, 204, 22 19 | 1993,12, 12617, 10, 0, 2,, 1, 7, 260, 62, 177, 21 20 | 1994,12, 12713, 3, 0, 0,, 1, 2, 234, 40, 177, 17 21 | 1995,12, 12858, 7, 1, 0,, 3, 3, 433, 78, 342, 13 22 | 1996,12, 12918, 21, 0, 1,, 5, 15, 646, 174, 434, 38 23 | 1997,12, 13057, 19, 0, 1,, 4, 14, 670, 117, 526, 27 24 | 1998,12, 12639, 10, 0, 1,, 2, 7, 509, 101, 391, 17 25 | 1999,12, 12700, 13, 1, 0,, 4, 8, 449, 60, 379, 10 26 | 2000,12, 12938, 15, 0, 2,, 5, 8, 607, 98, 507, 2 27 | 2001,12, 12988, 22, 1, 3,, 4, 14, 570, 89, 477, 4 28 | 2002,12, 13052, 50, 0, 5,, 4, 41, 531, 79, 450, 2 29 | 2003,12, 13123, 31, 0, 2,, 3, 26, 428, 81, 343, 4 30 | 2004,12, 13366, 38, 0, 1,, 3, 34, 618, 125, 465, 28 31 | 2007,12, 13889, 44, 1, 3,, 3, 37, 691, 96, 557, 38 32 | 2008,12, 14040, 35, 1, 2,, 9, 23, 460, 106, 323, 31 33 | 2009,12, 14189, 38, 1, 4,, 4, 29, 519, 89, 394, 36 34 | 2010,11, 14012, 0, 0, 0,, 0, 0, 0, 0, 0, 0 35 | 2011,12, 14079, 27, 0, 2,, 6, 19, 488, 102, 369, 17 36 | 2012,12, 14219, 22, 0, 5,, 2, 15, 470, 90, 354, 26 37 | 2013,5, 14103, 9, 0,, 2, 2, 5, 184, 41, 135, 8 38 | 39 | 40 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 41 | 42 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 43 | 44 | 45 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 46 | 47 | 48 | 49 | Crime rates are not available for agencies that report data for less than 12 months of a year. 50 | 51 | 52 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 53 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /inst/testdata/huntsville_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Huntsville Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 150681, 684, 11, 71,, 206, 396, 10191, 2260, 7454, 477 12 | 1986,12, 151880, 787, 19, 61,, 201, 506, 11011, 2353, 8182, 476 13 | 1987,12, 164658, 761, 16, 68,, 213, 464, 11976, 2217, 9219, 540 14 | 1988,12, 163618, 910, 15, 83,, 225, 587, 12958, 2447, 9999, 512 15 | 1989,12, 159553, 848, 12, 85,, 234, 517, 13113, 2188, 10229, 696 16 | 1990,12, 159789, 889, 18, 83,, 293, 495, 13768, 2181, 10889, 698 17 | 1991,4, 161703, 340, 9, 4,, 62, 265, 4256, 770, 3252, 234 18 | 1992,12, 163560, 1515, 20, 73,, 405, 1017, 14335, 2732, 10945, 658 19 | 1993,12, 165252, 2171, 18, 82,, 320, 1751, 13523, 2571, 10002, 950 20 | 1994,12, 166514, 1802, 18, 88,, 382, 1314, 13819, 2710, 10114, 995 21 | 1995,12, 161617, 1275, 10, 56,, 384, 825, 11827, 2413, 8393, 1021 22 | 1996,12, 162376, 1339, 11, 71,, 310, 947, 12991, 2251, 9516, 1224 23 | 1997,12, 164124, 1408, 16, 99,, 372, 921, 12129, 2261, 8760, 1108 24 | 1998,12, 173145, 1245, 11, 92,, 301, 841, 10471, 1848, 7521, 1102 25 | 1999,12, 176701, 1492, 19, 106,, 302, 1065, 11457, 2034, 8288, 1135 26 | 2000,12, 158216, 1244, 8, 62,, 299, 875, 10995, 1882, 8330, 783 27 | 2001,12, 158830, 1039, 15, 109,, 345, 570, 10374, 1802, 7802, 770 28 | 2002,12, 159618, 961, 5, 82,, 315, 559, 9206, 1714, 6718, 774 29 | 2003,12, 163052, 988, 19, 84,, 316, 569, 9388, 1740, 6774, 874 30 | 2004,12, 165311, 1109, 6, 93,, 363, 647, 10387, 1924, 7537, 926 31 | 2005,12, 165147, 1220, 22, 88,, 500, 610, 11513, 2446, 7979, 1088 32 | 2006,12, 167817, 1439, 16, 100,, 617, 706, 11495, 2493, 7643, 1359 33 | 2007,12, 169391, 1379, 21, 96,, 586, 676, 10731, 2283, 7282, 1166 34 | 2008,12, 172794, 1222, 18, 93,, 412, 699, 10647, 2369, 7196, 1082 35 | 2009,12, 178601, 1164, 13, 89,, 433, 629, 9790, 2520, 6375, 895 36 | 2010,12, 180105, 1182, 12, 76,, 463, 631, 9768, 2677, 6230, 861 37 | 2011,12, 180972, 1518, 13, 51,, 405, 1049, 9749, 2677, 6306, 766 38 | 2012,12, 183691, 1696, 14, 72,, 456, 1154, 9261, 2165, 6386, 710 39 | 2013,12, 184738, 1507, 24,, 87, 391, 1005, 9216, 1884, 6629, 703 40 | 2014,12, 187624, 1467, 15,, 104, 390, 958, 9161, 1912, 6521, 728 41 | 42 | 43 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 44 | 45 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 46 | 47 | 48 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 49 | 50 | 51 | 52 | Crime rates are not available for agencies that report data for less than 12 months of a year. 53 | 54 | 55 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 56 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /inst/testdata/madison_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Madison Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 4563, 33, 0, 0,, 3, 30, 265, 85, 161, 19 12 | 1986,12, 5038, 42, 0, 1,, 5, 36, 309, 99, 202, 8 13 | 1987,12, 5914, 37, 1, 2,, 6, 28, 440, 106, 321, 13 14 | 1988,11, 5877, 22, 0, 2,, 3, 17, 443, 97, 323, 23 15 | 1989,12, 7485, 38, 0, 0,, 4, 34, 486, 96, 368, 22 16 | 1990,12, 14904, 26, 1, 0,, 0, 25, 413, 64, 327, 22 17 | 1991,12, 15082, 41, 0, 1,, 7, 33, 360, 69, 273, 18 18 | 1992,12, 15255, 57, 0, 6,, 9, 42, 486, 87, 378, 21 19 | 1993,12, 17759, 42, 0, 2,, 7, 33, 413, 73, 309, 31 20 | 1994,12, 17894, 43, 1, 5,, 8, 29, 549, 82, 437, 30 21 | 1995,12, 20404, 38, 0, 1,, 9, 28, 538, 120, 379, 39 22 | 1996,12, 20499, 49, 0, 3,, 4, 42, 549, 104, 404, 41 23 | 1997,12, 20719, 75, 0, 5,, 13, 57, 785, 150, 584, 51 24 | 1998,12, 23997, 49, 0, 3,, 20, 26, 727, 157, 512, 58 25 | 1999,12, 25504, 75, 0, 8,, 14, 53, 761, 119, 587, 55 26 | 2000,12, 29329, 59, 0, 3,, 20, 36, 812, 151, 626, 35 27 | 2001,12, 29443, 61, 1, 8,, 15, 37, 854, 154, 656, 44 28 | 2002,12, 29589, 56, 2, 6,, 21, 27, 874, 192, 635, 47 29 | 2003,12, 32438, 52, 1, 8,, 15, 28, 1064, 166, 843, 55 30 | 2004,12, 34303, 63, 0, 8,, 19, 36, 734, 160, 531, 43 31 | 2008,12, 39529, 96, 0, 7,, 38, 51, 1082, 270, 767, 45 32 | 2009,12, 39880, 59, 3, 3,, 17, 36, 877, 176, 669, 32 33 | 2010,12, 42938, 82, 1, 12,, 26, 43, 925, 166, 712, 47 34 | 2011,12, 43145, 103, 1, 19,, 20, 63, 902, 217, 630, 55 35 | 2012,12, 43860, 90, 0, 4,, 20, 66, 1068, 219, 805, 44 36 | 2013,12, 45540, 133, 2,, 17, 27, 87, 1200, 214, 947, 39 37 | 2014,12, 46441, 150, 2,, 11, 20, 117, 943, 151, 749, 43 38 | 39 | 40 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 41 | 42 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 43 | 44 | 45 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 46 | 47 | 48 | 49 | Crime rates are not available for agencies that report data for less than 12 months of a year. 50 | 51 | 52 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 53 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /inst/testdata/oxford_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Oxford Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 9395, 45, 0, 3,, 7, 35, 453, 112, 325, 16 12 | 1986,12, 10306, 69, 1, 1,, 11, 56, 503, 127, 352, 24 13 | 1987,12, 10559, 84, 0, 1,, 12, 71, 504, 83, 386, 35 14 | 1988,12, 10472, 96, 0, 1,, 9, 86, 534, 122, 370, 42 15 | 1989,12, 11066, 71, 0, 0,, 6, 65, 383, 69, 286, 28 16 | 1990,12, 9362, 95, 0, 3,, 11, 81, 584, 110, 423, 51 17 | 1991,12, 9474, 182, 0, 6,, 20, 156, 671, 159, 470, 42 18 | 1992,12, 9582, 246, 0, 6,, 21, 219, 809, 184, 566, 59 19 | 1993,12, 9875, 271, 1, 7,, 16, 247, 885, 192, 643, 50 20 | 1994,12, 9950, 213, 0, 12,, 17, 184, 1021, 195, 765, 61 21 | 1995,12, 10506, 230, 0, 4,, 22, 204, 883, 177, 668, 38 22 | 1996,12, 10555, 230, 0, 3,, 33, 194, 1160, 230, 809, 121 23 | 1997,12, 10668, 124, 0, 3,, 29, 92, 1298, 267, 922, 109 24 | 1998,12, 10540, 81, 1, 7,, 34, 39, 1001, 116, 810, 75 25 | 1999,12, 11076, 117, 0, 5,, 30, 82, 1179, 148, 920, 111 26 | 2001,12, 14649, 130, 1, 9,, 38, 82, 1314, 184, 1032, 98 27 | 2002,12, 14722, 84, 0, 2,, 33, 49, 1233, 173, 939, 121 28 | 2003,12, 15260, 125, 1, 4,, 33, 87, 1331, 229, 1011, 91 29 | 2004,11, 15571, 90, 2, 7,, 37, 44, 1146, 227, 842, 77 30 | 2007,12, 20396, 112, 1, 11,, 48, 52, 1232, 230, 936, 66 31 | 2008,12, 20511, 103, 1, 12,, 47, 43, 1191, 179, 957, 55 32 | 2009,12, 20808, 135, 0, 9,, 37, 89, 1427, 248, 1112, 67 33 | 2010,12, 21348, 69, 4, 1,, 8, 56, 1242, 186, 998, 58 34 | 2011,12, 21451, 108, 4, 6,, 20, 78, 1301, 226, 1003, 72 35 | 2012,12, 21306, 76, 1, 9,, 28, 38, 1250, 222, 982, 46 36 | 2013,12, 21261, 62, 2,, 7, 8, 45, 1130, 206, 874, 50 37 | 2014,12, 21208, 73, 2,, 2, 10, 59, 1040, 134, 878, 28 38 | 39 | 40 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 41 | 42 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 43 | 44 | 45 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 46 | 47 | 48 | 49 | Crime rates are not available for agencies that report data for less than 12 months of a year. 50 | 51 | " Oxford Police Dept, Alabama 2010 - The FBI determined that the agency's 2010 robbery data were underreported." 52 | 53 | 54 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 55 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /inst/testdata/ozark_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Ozark Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 13887, 158, 0, 4,, 15, 139, 728, 158, 551, 19 12 | 1986,12, 13300, 192, 0, 3,, 15, 174, 674, 158, 499, 17 13 | 1987,12, 15023, 184, 6, 3,, 18, 157, 786, 147, 605, 34 14 | 1988,12, 14979, 174, 1, 6,, 20, 147, 811, 199, 586, 26 15 | 1989,12, 15561, 140, 1, 8,, 10, 121, 693, 93, 555, 45 16 | 1990,12, 12922, 68, 1, 4,, 10, 53, 492, 95, 373, 24 17 | 1991,12, 13076, 162, 1, 1,, 10, 150, 581, 108, 454, 19 18 | 1992,12, 13226, 235, 1, 1,, 9, 224, 646, 100, 534, 12 19 | 1993,12, 12878, 200, 1, 5,, 18, 176, 591, 80, 495, 16 20 | 1994,12, 12976, 236, 2, 7,, 15, 212, 785, 109, 653, 23 21 | 1995,12, 13311, 191, 5, 4,, 14, 168, 715, 107, 570, 38 22 | 1996,12, 13373, 85, 0, 3,, 19, 63, 549, 115, 411, 23 23 | 1997,12, 13517, 90, 2, 3,, 21, 64, 617, 100, 484, 33 24 | 1998,12, 12807, 84, 1, 7,, 23, 53, 723, 109, 555, 59 25 | 1999,12, 12712, 89, 2, 4,, 15, 68, 618, 98, 469, 51 26 | 2000,12, 15119, 78, 4, 8,, 11, 55, 671, 82, 552, 37 27 | 2001,12, 15178, 60, 2, 4,, 9, 45, 730, 117, 579, 34 28 | 2003,12, 15024, 70, 0, 7,, 6, 57, 587, 101, 437, 49 29 | 2004,12, 15085, 93, 1, 10,, 11, 71, 581, 108, 428, 45 30 | 2005,12, 15044, 112, 2, 7,, 15, 88, 689, 136, 493, 60 31 | 2006,12, 14967, 146, 0, 12,, 32, 102, 777, 200, 517, 60 32 | 2007,12, 14656, 118, 3, 9,, 19, 87, 716, 147, 503, 66 33 | 2008,12, 14584, 89, 0, 7,, 23, 59, 713, 154, 514, 45 34 | 2009,12, 14670, 108, 1, 8,, 24, 75, 686, 204, 459, 23 35 | 2010,12, 14907, 72, 1, 5,, 7, 59, 452, 5, 426, 21 36 | 2011,12, 14979, 110, 1, 6,, 24, 79, 886, 161, 668, 57 37 | 2012,12, 14908, 103, 0, 2,, 21, 80, 793, 173, 590, 30 38 | 2013,12, 14897, 86, 0,, 14, 17, 55, 878, 160, 686, 32 39 | 2014,12, 14845, 67, 1,, 19, 4, 43, 900, 184, 681, 35 40 | 41 | 42 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 43 | 44 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 45 | 46 | 47 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 48 | 49 | 50 | 51 | Crime rates are not available for agencies that report data for less than 12 months of a year. 52 | 53 | 54 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 55 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /inst/testdata/tuscaloosa_alabama.csv: -------------------------------------------------------------------------------- 1 | Uniform Crime Reporting Statistics - UCR Data Online 2 | http://www.ucrdatatool.gov/ 3 | 4 | 5 | "Crime reported by Tuscaloosa Police Dept, Alabama" 6 | 7 | ,,,Number of offenses reported,,,,,,,,,,, 8 | ,,,Violent crime,,,,,,Property crime,,,,, 9 | 10 | Year,Months,Population,Violent crime total,Murder and nonnegligent Manslaughter,Legacy rape /1,Revised rape /2,Robbery,Aggravated assault,Property crime total,Burglary,Larceny-theft,Motor vehicle theft, 11 | 1985,12, 75147, 541, 4, 39,, 112, 386, 4435, 1112, 3089, 234 12 | 1986,11, 74302, 540, 3, 31,, 95, 411, 4325, 1087, 2991, 247 13 | 1987,12, 74389, 1046, 9, 44,, 128, 865, 5060, 1398, 3326, 336 14 | 1988,12, 76153, 440, 4, 28,, 97, 311, 3681, 1062, 2460, 159 15 | 1989,12, 74344, 677, 7, 37,, 147, 486, 5714, 1330, 4091, 293 16 | 1990,12, 77759, 1097, 11, 59,, 199, 828, 6818, 1394, 5025, 399 17 | 1991,12, 78690, 1025, 7, 67,, 223, 728, 7264, 1693, 5067, 504 18 | 1992,12, 79594, 1201, 8, 75,, 274, 844, 7631, 1585, 5665, 381 19 | 1993,12, 79664, 925, 8, 56,, 282, 579, 7851, 1093, 6421, 337 20 | 1994,12, 80272, 927, 7, 65,, 260, 595, 9032, 1100, 7640, 292 21 | 1995,12, 80440, 809, 10, 61,, 284, 454, 9788, 1319, 8176, 293 22 | 1996,12, 80818, 904, 5, 50,, 340, 509, 11045, 1346, 9322, 377 23 | 1997,12, 81688, 955, 5, 55,, 357, 538, 11400, 1544, 9432, 424 24 | 1998,12, 83995, 844, 8, 52,, 261, 523, 10432, 1476, 8464, 492 25 | 1999,12, 83718, 843, 13, 50,, 216, 564, 10144, 1556, 8233, 355 26 | 2000,12, 77906, 903, 9, 68,, 222, 604, 10307, 1314, 8689, 304 27 | 2001,12, 78208, 870, 6, 50,, 222, 592, 5558, 1348, 3948, 262 28 | 2002,12, 78596, 469, 5, 49,, 185, 230, 5305, 1012, 4036, 257 29 | 2003,12, 79400, 555, 7, 50,, 222, 276, 5063, 999, 3809, 255 30 | 2004,12, 79812, 471, 10, 46,, 184, 231, 5005, 1231, 3536, 238 31 | 2005,12, 80670, 504, 7, 39,, 200, 258, 5033, 1191, 3582, 260 32 | 2006,12, 82094, 604, 15, 47,, 221, 321, 5234, 1256, 3709, 269 33 | 2007,12, 83811, 557, 10, 32,, 264, 251, 5047, 1199, 3569, 279 34 | 2008,12, 90157, 470, 11, 28,, 199, 232, 5396, 1513, 3553, 330 35 | 2009,12, 91688, 418, 5, 28,, 195, 190, 5082, 1507, 3355, 220 36 | 2010,12, 90468, 449, 7, 31,, 190, 221, 4828, 1462, 3188, 178 37 | 2011,12, 90903, 432, 3, 39,, 194, 196, 4402, 1249, 2963, 190 38 | 2012,12, 91973, 478, 4, 37,, 170, 267, 4349, 1182, 2965, 202 39 | 2013,12, 94126, 434, 8,, 44, 161, 221, 4512, 1165, 3196, 151 40 | 2014,12, 96412, 466, 9,, 53, 176, 228, 4138, 1042, 2913, 183 41 | 42 | 43 | ,1. The figures shown in this column for the offense of rape were estimated using the legacy UCR definition of rape - previously known as "Forcible" rape. See UCR Offense Definitions for further information. 44 | 45 | ,2. The figures shown in this column for the offense of rape were estimated using the revised Uniform Crime Reporting (UCR) definition of rape. In December 2011 the UCR program changed its definition of SRS rape to this revised definition. This change can be seen in the UCR data starting in 2013. Prior to 2013 this column will be blank. See UCR Offense Definitions for further information. 46 | 47 | 48 | "Notes: When data are unavailable, the cells are blank or the year is not presented." 49 | 50 | 51 | 52 | Crime rates are not available for agencies that report data for less than 12 months of a year. 53 | 54 | 55 | "Sources: FBI, Uniform Crime Reports, prepared by the National Archive of Criminal Justice Data" 56 | Date of download: Nov 22 2018 -------------------------------------------------------------------------------- /setup_files/arrests_agency_header_1974_1979.sps: -------------------------------------------------------------------------------- 1 | arrests_agency_header_1974_1979 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.4.0) on 2023-04-04 10:27:58. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1 8 | V2 2-3 9 | V3 4-10 10 | V4 11-12 11 | V5 13 12 | V6 14-15 13 | V7 16-17 14 | V8 18-20 15 | V9 21-23 16 | V10 24-28 17 | V11 29 18 | V12 30 19 | V13 31 20 | V14 32-38 21 | V15 39 22 | V16 40-63 23 | V17 64-69 24 | . 25 | 26 | variable labels 27 | V1 "identifier_code" 28 | V2 "state" 29 | V3 "ori" 30 | V4 "population_group" 31 | V5 "country_division" 32 | V6 "agency_header_designation" 33 | V7 "year" 34 | V8 "msa" 35 | V9 "county" 36 | V10 "sequence_number" 37 | V11 "suburban" 38 | V12 "core_city" 39 | V13 "covered_by" 40 | V14 "population" 41 | V15 "agency_count" 42 | V16 "agency_name" 43 | V17 "state_name" 44 | . 45 | 46 | value labels 47 | V2 48 | '50' "Alaska" 49 | '01' "Alabama" 50 | '03' "Arkansas" 51 | '54' "American Samoa" 52 | '02' "Arizona" 53 | '04' "California" 54 | '05' "Colorado" 55 | '06' "Connecticut" 56 | '52' "Canal Zone" 57 | '08' "District of Columbia" 58 | '07' "Delaware" 59 | '09' "Florida" 60 | '10' "Georgia" 61 | '55' "Guam" 62 | '51' "Hawaii" 63 | '14' "Iowa" 64 | '11' "Idaho" 65 | '12' "Illinois" 66 | '13' "Indiana" 67 | '15' "Kansas" 68 | '16' "Kentucky" 69 | '17' "Louisiana" 70 | '20' "Massachusetts" 71 | '19' "Maryland" 72 | '18' "Maine" 73 | '21' "Michigan" 74 | '22' "Minnesota" 75 | '24' "Missouri" 76 | '23' "Mississippi" 77 | '25' "Montana" 78 | '26' "Nebraska" 79 | '32' "North Carolina" 80 | '33' "North Dakota" 81 | '28' "New Hampshire" 82 | '29' "New Jersey" 83 | '30' "New Mexico" 84 | '27' "Nevada" 85 | '31' "New York" 86 | '34' "Ohio" 87 | '35' "Oklahoma" 88 | '36' "Oregon" 89 | '37' "Pennsylvania" 90 | '53' "Puerto Rico" 91 | '38' "Rhode Island" 92 | '39' "South Carolina" 93 | '40' "South Dakota" 94 | '41' "Tennessee" 95 | '42' "Texas" 96 | '43' "Utah" 97 | '62' "Virgin Islands" 98 | '45' "Virginia" 99 | '44' "Vermont" 100 | '46' "Washington" 101 | '48' "Wisconsin" 102 | '47' "West Virginia" 103 | '49' "Wyoming" 104 | V4 105 | '0 ' "possessions" 106 | '1 ' "city 250,000+" 107 | '1A' "city 1,000,000+" 108 | '1B' "city 500,000 thru 999,999" 109 | '1C' "city 250,000 thru 499,999" 110 | '2 ' "city 100,000 thru 249,999" 111 | '3 ' "city 50,000 thru 99,999" 112 | '4 ' "city 25,000 thru 49,999" 113 | '5 ' "city 10,000 thru 24,999" 114 | '6 ' "city 2,500 thru 9,999" 115 | '7 ' "city under 2,500" 116 | '8 ' "non-msa county" 117 | '8A' "non-msa county 100,000+" 118 | '8B' "non-msa county 25,000 thru 99,999" 119 | '8C' "non-msa county 10,000 thru 24,999" 120 | '8D' "non-msa county under 10,000" 121 | '8E' "non-msa state police" 122 | '9 ' "msa-county" 123 | '9A' "msa-county 100,000+" 124 | '9B' "msa-county 25,000 thru 99,999" 125 | '9C' "msa-county 10,000 thru 24,999" 126 | '9D' "msa-county under 10,000" 127 | '9E' "msa state police" 128 | V5 129 | '0' "Possessions" 130 | '1' "New England" 131 | '2' "Middle Atlantic" 132 | '3' "East North Central" 133 | '4' "West North Central" 134 | '5' "South Atlantic" 135 | '6' "East South Central" 136 | '7' "West South Central" 137 | '8' "Mountain" 138 | '9' "Pacific" 139 | 'A' "New England" 140 | 'B' "Middle Atlantic" 141 | 'C' "East North Central" 142 | 'D' "West North Central" 143 | 'E' "South Atlantic" 144 | 'F' "East South Central" 145 | 'G' "West South Central" 146 | 'H' "Mountain" 147 | 'I' "Pacific" 148 | V1 149 | '3' "ASR master file" 150 | V6 151 | '00' "agency header" 152 | V11 153 | '1' "suburban" 154 | '0' "non-suburban" 155 | V12 156 | 'Y' "agency is core city of an MSA" 157 | 'N' "agency is not a core city of an MSA" 158 | V13 159 | '0' "not covered by another agency" 160 | '1' "covered by another agency" 161 | . 162 | 163 | 164 | 165 | execute 166 | -------------------------------------------------------------------------------- /setup_files/arrests_agency_header_1980_present.sps: -------------------------------------------------------------------------------- 1 | arrests_agency_header_1980_present 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.4.0) on 2023-04-04 10:27:58. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1 8 | V2 2-3 9 | V3 4-10 10 | V4 11-12 11 | V5 13 12 | V6 14-15 13 | V7 16-17 14 | V8 18-20 15 | V9 21-23 16 | V10 24-28 17 | V11 29 18 | V12 30 19 | V13 31 20 | V14 32-40 21 | V15 41-64 22 | V16 65-70 23 | . 24 | 25 | variable labels 26 | V1 "identifier_code" 27 | V2 "state" 28 | V3 "ori" 29 | V4 "population_group" 30 | V5 "country_division" 31 | V6 "agency_header_designation" 32 | V7 "year" 33 | V8 "msa" 34 | V9 "county" 35 | V10 "sequence_number" 36 | V11 "suburban" 37 | V12 "core_city" 38 | V13 "covered_by" 39 | V14 "population" 40 | V15 "agency_name" 41 | V16 "state_name" 42 | . 43 | 44 | value labels 45 | V2 46 | '50' "Alaska" 47 | '01' "Alabama" 48 | '03' "Arkansas" 49 | '54' "American Samoa" 50 | '02' "Arizona" 51 | '04' "California" 52 | '05' "Colorado" 53 | '06' "Connecticut" 54 | '52' "Canal Zone" 55 | '08' "District of Columbia" 56 | '07' "Delaware" 57 | '09' "Florida" 58 | '10' "Georgia" 59 | '55' "Guam" 60 | '51' "Hawaii" 61 | '14' "Iowa" 62 | '11' "Idaho" 63 | '12' "Illinois" 64 | '13' "Indiana" 65 | '15' "Kansas" 66 | '16' "Kentucky" 67 | '17' "Louisiana" 68 | '20' "Massachusetts" 69 | '19' "Maryland" 70 | '18' "Maine" 71 | '21' "Michigan" 72 | '22' "Minnesota" 73 | '24' "Missouri" 74 | '23' "Mississippi" 75 | '25' "Montana" 76 | '26' "Nebraska" 77 | '32' "North Carolina" 78 | '33' "North Dakota" 79 | '28' "New Hampshire" 80 | '29' "New Jersey" 81 | '30' "New Mexico" 82 | '27' "Nevada" 83 | '31' "New York" 84 | '34' "Ohio" 85 | '35' "Oklahoma" 86 | '36' "Oregon" 87 | '37' "Pennsylvania" 88 | '53' "Puerto Rico" 89 | '38' "Rhode Island" 90 | '39' "South Carolina" 91 | '40' "South Dakota" 92 | '41' "Tennessee" 93 | '42' "Texas" 94 | '43' "Utah" 95 | '62' "Virgin Islands" 96 | '45' "Virginia" 97 | '44' "Vermont" 98 | '46' "Washington" 99 | '48' "Wisconsin" 100 | '47' "West Virginia" 101 | '49' "Wyoming" 102 | V4 103 | '0 ' "possessions" 104 | '1 ' "city 250,000+" 105 | '1A' "city 1,000,000+" 106 | '1B' "city 500,000 thru 999,999" 107 | '1C' "city 250,000 thru 499,999" 108 | '2 ' "city 100,000 thru 249,999" 109 | '3 ' "city 50,000 thru 99,999" 110 | '4 ' "city 25,000 thru 49,999" 111 | '5 ' "city 10,000 thru 24,999" 112 | '6 ' "city 2,500 thru 9,999" 113 | '7 ' "city under 2,500" 114 | '8 ' "non-msa county" 115 | '8A' "non-msa county 100,000+" 116 | '8B' "non-msa county 25,000 thru 99,999" 117 | '8C' "non-msa county 10,000 thru 24,999" 118 | '8D' "non-msa county under 10,000" 119 | '8E' "non-msa state police" 120 | '9 ' "msa-county" 121 | '9A' "msa-county 100,000+" 122 | '9B' "msa-county 25,000 thru 99,999" 123 | '9C' "msa-county 10,000 thru 24,999" 124 | '9D' "msa-county under 10,000" 125 | '9E' "msa state police" 126 | V5 127 | '0' "Possessions" 128 | '1' "New England" 129 | '2' "Middle Atlantic" 130 | '3' "East North Central" 131 | '4' "West North Central" 132 | '5' "South Atlantic" 133 | '6' "East South Central" 134 | '7' "West South Central" 135 | '8' "Mountain" 136 | '9' "Pacific" 137 | 'A' "New England" 138 | 'B' "Middle Atlantic" 139 | 'C' "East North Central" 140 | 'D' "West North Central" 141 | 'E' "South Atlantic" 142 | 'F' "East South Central" 143 | 'G' "West South Central" 144 | 'H' "Mountain" 145 | 'I' "Pacific" 146 | V1 147 | '3' "ASR master file" 148 | V6 149 | '00' "agency header" 150 | V11 151 | '1' "suburban" 152 | '0' "non-suburban" 153 | V12 154 | 'Y' "agency is core city of an MSA" 155 | 'N' "agency is not a core city of an MSA" 156 | V13 157 | '0' "not covered by another agency" 158 | '1' "covered by another agency" 159 | . 160 | 161 | 162 | 163 | execute 164 | -------------------------------------------------------------------------------- /setup_files/arrests_agency_header_post_2020.sps: -------------------------------------------------------------------------------- 1 | arrests_agency_header_post_2020 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.4.0) on 2023-04-04 10:27:58. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1 8 | V2 2-3 9 | V3 4-10 10 | V4 11-12 11 | V5 13 12 | V6 14-15 13 | V7 16-18 14 | V8 19 15 | V9 20 16 | V10 21 17 | V11 22 18 | V12 23-25 19 | V13 26-27 20 | V14 28-32 21 | V15 33-35 22 | V16 36-39 23 | V17 40 24 | V18 41-50 25 | V19 51-109 26 | V20 110 27 | V21 111-135 28 | . 29 | 30 | variable labels 31 | V1 "identifier_code" 32 | V2 "state" 33 | V3 "ori" 34 | V4 "population_group" 35 | V5 "country_division" 36 | V6 "year" 37 | V7 "msa" 38 | V8 "suburban" 39 | V9 "not_used1" 40 | V10 "report_indication" 41 | V11 "adjustment" 42 | V12 "offense" 43 | V13 "not_used2" 44 | V14 "sequence_number" 45 | V15 "county" 46 | V16 "not_used3" 47 | V17 "core_city" 48 | V18 "population" 49 | V19 "not_used4" 50 | V20 "agency_count" 51 | V21 "agency_name" 52 | . 53 | 54 | value labels 55 | V2 56 | '50' "Alaska" 57 | '01' "Alabama" 58 | '03' "Arkansas" 59 | '54' "American Samoa" 60 | '02' "Arizona" 61 | '04' "California" 62 | '05' "Colorado" 63 | '06' "Connecticut" 64 | '52' "Canal Zone" 65 | '08' "District of Columbia" 66 | '07' "Delaware" 67 | '09' "Florida" 68 | '10' "Georgia" 69 | '55' "Guam" 70 | '51' "Hawaii" 71 | '14' "Iowa" 72 | '11' "Idaho" 73 | '12' "Illinois" 74 | '13' "Indiana" 75 | '15' "Kansas" 76 | '16' "Kentucky" 77 | '17' "Louisiana" 78 | '20' "Massachusetts" 79 | '19' "Maryland" 80 | '18' "Maine" 81 | '21' "Michigan" 82 | '22' "Minnesota" 83 | '24' "Missouri" 84 | '23' "Mississippi" 85 | '25' "Montana" 86 | '26' "Nebraska" 87 | '32' "North Carolina" 88 | '33' "North Dakota" 89 | '28' "New Hampshire" 90 | '29' "New Jersey" 91 | '30' "New Mexico" 92 | '27' "Nevada" 93 | '31' "New York" 94 | '34' "Ohio" 95 | '35' "Oklahoma" 96 | '36' "Oregon" 97 | '37' "Pennsylvania" 98 | '53' "Puerto Rico" 99 | '38' "Rhode Island" 100 | '39' "South Carolina" 101 | '40' "South Dakota" 102 | '41' "Tennessee" 103 | '42' "Texas" 104 | '43' "Utah" 105 | '62' "Virgin Islands" 106 | '45' "Virginia" 107 | '44' "Vermont" 108 | '46' "Washington" 109 | '48' "Wisconsin" 110 | '47' "West Virginia" 111 | '49' "Wyoming" 112 | V4 113 | '0 ' "possessions" 114 | '1 ' "city 250,000+" 115 | '1A' "city 1,000,000+" 116 | '1B' "city 500,000 thru 999,999" 117 | '1C' "city 250,000 thru 499,999" 118 | '2 ' "city 100,000 thru 249,999" 119 | '3 ' "city 50,000 thru 99,999" 120 | '4 ' "city 25,000 thru 49,999" 121 | '5 ' "city 10,000 thru 24,999" 122 | '6 ' "city 2,500 thru 9,999" 123 | '7 ' "city under 2,500" 124 | '8 ' "non-msa county" 125 | '8A' "non-msa county 100,000+" 126 | '8B' "non-msa county 25,000 thru 99,999" 127 | '8C' "non-msa county 10,000 thru 24,999" 128 | '8D' "non-msa county under 10,000" 129 | '8E' "non-msa state police" 130 | '9 ' "msa-county" 131 | '9A' "msa-county 100,000+" 132 | '9B' "msa-county 25,000 thru 99,999" 133 | '9C' "msa-county 10,000 thru 24,999" 134 | '9D' "msa-county under 10,000" 135 | '9E' "msa state police" 136 | V5 137 | '0' "Possessions" 138 | '1' "New England" 139 | '2' "Middle Atlantic" 140 | '3' "East North Central" 141 | '4' "West North Central" 142 | '5' "South Atlantic" 143 | '6' "East South Central" 144 | '7' "West South Central" 145 | '8' "Mountain" 146 | '9' "Pacific" 147 | 'A' "New England" 148 | 'B' "Middle Atlantic" 149 | 'C' "East North Central" 150 | 'D' "West North Central" 151 | 'E' "South Atlantic" 152 | 'F' "East South Central" 153 | 'G' "West South Central" 154 | 'H' "Mountain" 155 | 'I' "Pacific" 156 | V1 157 | '3' "ASR master file" 158 | V8 159 | '1' "suburban" 160 | '0' "non-suburban" 161 | V10 162 | '0' "juvenile and adult reported" 163 | '1' "juvenile only reported" 164 | '2' "adult only reported" 165 | '3' "not reported" 166 | V11 167 | '0' "age, race, and ethnic origin reported" 168 | '1' "no age reported" 169 | '2' "no race reported" 170 | '3' "no ethnic origin reported" 171 | '4' "no race or ethnic origin reported" 172 | '5' "no age or ethnic origin reported" 173 | '6' "no age or race reported" 174 | V17 175 | 'Y' "agency is core city of an MSA" 176 | 'N' "agency is not a core city of an MSA" 177 | . 178 | 179 | 180 | 181 | execute 182 | -------------------------------------------------------------------------------- /setup_files/arrests_monthly_header_1974_1979.sps: -------------------------------------------------------------------------------- 1 | arrests_monthly_header_1974_1979 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.4.0) on 2023-04-04 10:27:58. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1 8 | V2 2-3 9 | V3 4-10 10 | V4 11-12 11 | V5 13 12 | V6 14-15 13 | V7 16-17 14 | V8 18-20 15 | V9 21 16 | V10 22 17 | V11 23 18 | V12 24 19 | V13 25-31 20 | V14 32-38 21 | V15 39-45 22 | V16 46 23 | V17 47-51 24 | V18 52-56 25 | V19 57-61 26 | V20 62-66 27 | V21 67-71 28 | . 29 | 30 | variable labels 31 | V1 "identifier_code" 32 | V2 "state" 33 | V3 "ori" 34 | V4 "population_group" 35 | V5 "country_division" 36 | V6 "month" 37 | V7 "year" 38 | V8 "monthly_header_designation" 39 | V9 "breakdown_indicator" 40 | V10 "age_race_ethnicity_indicator" 41 | V11 "juv_and_adult_indicators" 42 | V12 "zero_data_indicator" 43 | V13 "date_of_last_update" 44 | V14 "date_of_1st_previous_update" 45 | V15 "date_of_2nd_previous_update" 46 | V16 "juv_disposition_indicator" 47 | V17 "juv_handled_within_department" 48 | V18 "juv_referred_to_juv_court" 49 | V19 "juv_referred_to_welfare" 50 | V20 "juv_referred_to_police" 51 | V21 "juv_referred_to_crim_court" 52 | . 53 | 54 | value labels 55 | V2 56 | '50' "Alaska" 57 | '01' "Alabama" 58 | '03' "Arkansas" 59 | '54' "American Samoa" 60 | '02' "Arizona" 61 | '04' "California" 62 | '05' "Colorado" 63 | '06' "Connecticut" 64 | '52' "Canal Zone" 65 | '08' "District of Columbia" 66 | '07' "Delaware" 67 | '09' "Florida" 68 | '10' "Georgia" 69 | '55' "Guam" 70 | '51' "Hawaii" 71 | '14' "Iowa" 72 | '11' "Idaho" 73 | '12' "Illinois" 74 | '13' "Indiana" 75 | '15' "Kansas" 76 | '16' "Kentucky" 77 | '17' "Louisiana" 78 | '20' "Massachusetts" 79 | '19' "Maryland" 80 | '18' "Maine" 81 | '21' "Michigan" 82 | '22' "Minnesota" 83 | '24' "Missouri" 84 | '23' "Mississippi" 85 | '25' "Montana" 86 | '26' "Nebraska" 87 | '32' "North Carolina" 88 | '33' "North Dakota" 89 | '28' "New Hampshire" 90 | '29' "New Jersey" 91 | '30' "New Mexico" 92 | '27' "Nevada" 93 | '31' "New York" 94 | '34' "Ohio" 95 | '35' "Oklahoma" 96 | '36' "Oregon" 97 | '37' "Pennsylvania" 98 | '53' "Puerto Rico" 99 | '38' "Rhode Island" 100 | '39' "South Carolina" 101 | '40' "South Dakota" 102 | '41' "Tennessee" 103 | '42' "Texas" 104 | '43' "Utah" 105 | '62' "Virgin Islands" 106 | '45' "Virginia" 107 | '44' "Vermont" 108 | '46' "Washington" 109 | '48' "Wisconsin" 110 | '47' "West Virginia" 111 | '49' "Wyoming" 112 | V4 113 | '0 ' "possessions" 114 | '1 ' "city 250,000+" 115 | '1A' "city 1,000,000+" 116 | '1B' "city 500,000 thru 999,999" 117 | '1C' "city 250,000 thru 499,999" 118 | '2 ' "city 100,000 thru 249,999" 119 | '3 ' "city 50,000 thru 99,999" 120 | '4 ' "city 25,000 thru 49,999" 121 | '5 ' "city 10,000 thru 24,999" 122 | '6 ' "city 2,500 thru 9,999" 123 | '7 ' "city under 2,500" 124 | '8 ' "non-msa county" 125 | '8A' "non-msa county 100,000+" 126 | '8B' "non-msa county 25,000 thru 99,999" 127 | '8C' "non-msa county 10,000 thru 24,999" 128 | '8D' "non-msa county under 10,000" 129 | '8E' "non-msa state police" 130 | '9 ' "msa-county" 131 | '9A' "msa-county 100,000+" 132 | '9B' "msa-county 25,000 thru 99,999" 133 | '9C' "msa-county 10,000 thru 24,999" 134 | '9D' "msa-county under 10,000" 135 | '9E' "msa state police" 136 | V5 137 | '0' "Possessions" 138 | '1' "New England" 139 | '2' "Middle Atlantic" 140 | '3' "East North Central" 141 | '4' "West North Central" 142 | '5' "South Atlantic" 143 | '6' "East South Central" 144 | '7' "West South Central" 145 | '8' "Mountain" 146 | '9' "Pacific" 147 | 'A' "New England" 148 | 'B' "Middle Atlantic" 149 | 'C' "East North Central" 150 | 'D' "West North Central" 151 | 'E' "South Atlantic" 152 | 'F' "East South Central" 153 | 'G' "West South Central" 154 | 'H' "Mountain" 155 | 'I' "Pacific" 156 | V1 157 | '3' "ASR master file" 158 | V8 159 | '000' "monthly header" 160 | V9 161 | '' "totals and breakdowns for both offenses of drugs and gambling" 162 | '1' "totals for both but no breakdowns for either" 163 | '2' "totals for drugs but no breakdowns" 164 | '3' "totals for gambling but no breakdowns" 165 | V10 166 | '' "data for age, race, and ethnic origin" 167 | '2' "no race information" 168 | '3' "no ethnic origin information" 169 | '4' "no race or ethnic origin information" 170 | V11 171 | '' "data for juvenile and adult" 172 | '1' "no adult information" 173 | '2' "no juvenile information" 174 | V12 175 | '0' "not used" 176 | '1' "reported no data" 177 | V16 178 | '' "update juvenile disposition data" 179 | '1' "no juvenile disposition data" 180 | '2' "delete juvenile disposition data" 181 | '3' "adjust juvenile disposition data" 182 | V6 183 | '1' "january" 184 | '2' "february" 185 | '3' "march" 186 | '4' "april" 187 | '5' "may" 188 | '6' "june" 189 | '7' "july" 190 | '8' "august" 191 | '9' "september" 192 | '10' "october" 193 | '11' "november" 194 | '12' "december" 195 | . 196 | 197 | 198 | 199 | execute 200 | -------------------------------------------------------------------------------- /setup_files/arrests_monthly_header_1980_present.sps: -------------------------------------------------------------------------------- 1 | arrests_monthly_header_1980_present 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.4.0) on 2023-04-04 10:27:58. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1 8 | V2 2-3 9 | V3 4-10 10 | V4 11-12 11 | V5 13 12 | V6 14-15 13 | V7 16-17 14 | V8 18-20 15 | V9 21 16 | V10 22 17 | V11 23 18 | V12 24 19 | V13 25-31 20 | V14 32-38 21 | V15 39-45 22 | V16 46 23 | V17 47-51 24 | V18 52-56 25 | V19 57-61 26 | V20 62-66 27 | V21 67-71 28 | . 29 | 30 | variable labels 31 | V1 "identifier_code" 32 | V2 "state" 33 | V3 "ori" 34 | V4 "population_group" 35 | V5 "country_division" 36 | V6 "month" 37 | V7 "year" 38 | V8 "monthly_header_designation" 39 | V9 "breakdown_indicator" 40 | V10 "age_race_ethnicity_indicator" 41 | V11 "juv_and_adult_indicators" 42 | V12 "zero_data_indicator" 43 | V13 "date_of_last_update" 44 | V14 "date_of_1st_previous_update" 45 | V15 "date_of_2nd_previous_update" 46 | V16 "juv_disposition_indicator" 47 | V17 "juv_handled_within_department" 48 | V18 "juv_referred_to_juv_court" 49 | V19 "juv_referred_to_welfare" 50 | V20 "juv_referred_to_police" 51 | V21 "juv_referred_to_crim_court" 52 | . 53 | 54 | value labels 55 | V2 56 | '50' "Alaska" 57 | '01' "Alabama" 58 | '03' "Arkansas" 59 | '54' "American Samoa" 60 | '02' "Arizona" 61 | '04' "California" 62 | '05' "Colorado" 63 | '06' "Connecticut" 64 | '52' "Canal Zone" 65 | '08' "District of Columbia" 66 | '07' "Delaware" 67 | '09' "Florida" 68 | '10' "Georgia" 69 | '55' "Guam" 70 | '51' "Hawaii" 71 | '14' "Iowa" 72 | '11' "Idaho" 73 | '12' "Illinois" 74 | '13' "Indiana" 75 | '15' "Kansas" 76 | '16' "Kentucky" 77 | '17' "Louisiana" 78 | '20' "Massachusetts" 79 | '19' "Maryland" 80 | '18' "Maine" 81 | '21' "Michigan" 82 | '22' "Minnesota" 83 | '24' "Missouri" 84 | '23' "Mississippi" 85 | '25' "Montana" 86 | '26' "Nebraska" 87 | '32' "North Carolina" 88 | '33' "North Dakota" 89 | '28' "New Hampshire" 90 | '29' "New Jersey" 91 | '30' "New Mexico" 92 | '27' "Nevada" 93 | '31' "New York" 94 | '34' "Ohio" 95 | '35' "Oklahoma" 96 | '36' "Oregon" 97 | '37' "Pennsylvania" 98 | '53' "Puerto Rico" 99 | '38' "Rhode Island" 100 | '39' "South Carolina" 101 | '40' "South Dakota" 102 | '41' "Tennessee" 103 | '42' "Texas" 104 | '43' "Utah" 105 | '62' "Virgin Islands" 106 | '45' "Virginia" 107 | '44' "Vermont" 108 | '46' "Washington" 109 | '48' "Wisconsin" 110 | '47' "West Virginia" 111 | '49' "Wyoming" 112 | V4 113 | '0 ' "possessions" 114 | '1 ' "city 250,000+" 115 | '1A' "city 1,000,000+" 116 | '1B' "city 500,000 thru 999,999" 117 | '1C' "city 250,000 thru 499,999" 118 | '2 ' "city 100,000 thru 249,999" 119 | '3 ' "city 50,000 thru 99,999" 120 | '4 ' "city 25,000 thru 49,999" 121 | '5 ' "city 10,000 thru 24,999" 122 | '6 ' "city 2,500 thru 9,999" 123 | '7 ' "city under 2,500" 124 | '8 ' "non-msa county" 125 | '8A' "non-msa county 100,000+" 126 | '8B' "non-msa county 25,000 thru 99,999" 127 | '8C' "non-msa county 10,000 thru 24,999" 128 | '8D' "non-msa county under 10,000" 129 | '8E' "non-msa state police" 130 | '9 ' "msa-county" 131 | '9A' "msa-county 100,000+" 132 | '9B' "msa-county 25,000 thru 99,999" 133 | '9C' "msa-county 10,000 thru 24,999" 134 | '9D' "msa-county under 10,000" 135 | '9E' "msa state police" 136 | V5 137 | '0' "Possessions" 138 | '1' "New England" 139 | '2' "Middle Atlantic" 140 | '3' "East North Central" 141 | '4' "West North Central" 142 | '5' "South Atlantic" 143 | '6' "East South Central" 144 | '7' "West South Central" 145 | '8' "Mountain" 146 | '9' "Pacific" 147 | 'A' "New England" 148 | 'B' "Middle Atlantic" 149 | 'C' "East North Central" 150 | 'D' "West North Central" 151 | 'E' "South Atlantic" 152 | 'F' "East South Central" 153 | 'G' "West South Central" 154 | 'H' "Mountain" 155 | 'I' "Pacific" 156 | V1 157 | '3' "ASR master file" 158 | V8 159 | '000' "monthly header" 160 | V9 161 | '' "totals and breakdowns for both offenses of drugs and gambling" 162 | '1' "totals for both but no breakdowns for either" 163 | '2' "totals for drugs but no breakdowns" 164 | '3' "totals for gambling but no breakdowns" 165 | V10 166 | '' "data for age, race, and ethnic origin" 167 | '2' "no race information" 168 | '3' "no ethnic origin information" 169 | '4' "no race or ethnic origin information" 170 | V11 171 | '' "data for juvenile and adult" 172 | '1' "no adult information" 173 | '2' "no juvenile information" 174 | V12 175 | '0' "not used" 176 | '1' "reported no data" 177 | V16 178 | '' "update juvenile disposition data" 179 | '1' "no juvenile disposition data" 180 | '2' "delete juvenile disposition data" 181 | '3' "adjust juvenile disposition data" 182 | V6 183 | '1' "january" 184 | '2' "february" 185 | '3' "march" 186 | '4' "april" 187 | '5' "may" 188 | '6' "june" 189 | '7' "july" 190 | '8' "august" 191 | '9' "september" 192 | '10' "october" 193 | '11' "november" 194 | '12' "december" 195 | . 196 | 197 | 198 | 199 | execute 200 | -------------------------------------------------------------------------------- /setup_files/crime_data_crosswalk.dta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/setup_files/crime_data_crosswalk.dta -------------------------------------------------------------------------------- /setup_files/nibrs_administrative_segment.sps: -------------------------------------------------------------------------------- 1 | nibrs_administrative_segment 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.5.0) on 2022-10-06 05:18:10. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1-2 8 | V2 3-4 9 | V3 5-13 10 | V4 14-25 11 | V5 26-33 12 | V6 34 13 | V7 35-36 14 | V8 37-38 15 | V9 39-41 16 | V10 42-43 17 | V11 44-45 18 | V12 46-49 19 | V13 50 20 | V14 51-58 21 | . 22 | 23 | variable labels 24 | V1 "segment_level" 25 | V2 "state" 26 | V3 "ori" 27 | V4 "incident_number" 28 | V5 "incident_date" 29 | V6 "report_date_indicator" 30 | V7 "incident_date_hour" 31 | V8 "total_offense_segments" 32 | V9 "total_victim_segments" 33 | V10 "total_offender_segments" 34 | V11 "total_arrestee_segments" 35 | V12 "city_submissions" 36 | V13 "cleared_exceptionally" 37 | V14 "exceptional_clearance_date" 38 | . 39 | 40 | value labels 41 | V2 42 | '50' "Alaska" 43 | '01' "Alabama" 44 | '03' "Arkansas" 45 | '54' "American Samoa" 46 | '02' "Arizona" 47 | '04' "California" 48 | '05' "Colorado" 49 | '06' "Connecticut" 50 | '52' "Canal Zone" 51 | '08' "District of Columbia" 52 | '07' "Delaware" 53 | '09' "Florida" 54 | '10' "Georgia" 55 | '55' "Guam" 56 | '51' "Hawaii" 57 | '14' "Iowa" 58 | '11' "Idaho" 59 | '12' "Illinois" 60 | '13' "Indiana" 61 | '15' "Kansas" 62 | '16' "Kentucky" 63 | '17' "Louisiana" 64 | '20' "Massachusetts" 65 | '19' "Maryland" 66 | '18' "Maine" 67 | '21' "Michigan" 68 | '22' "Minnesota" 69 | '24' "Missouri" 70 | '23' "Mississippi" 71 | '25' "Montana" 72 | '26' "Nebraska" 73 | '32' "North Carolina" 74 | '33' "North Dakota" 75 | '28' "New Hampshire" 76 | '29' "New Jersey" 77 | '30' "New Mexico" 78 | '27' "Nevada" 79 | '31' "New York" 80 | '34' "Ohio" 81 | '35' "Oklahoma" 82 | '36' "Oregon" 83 | '37' "Pennsylvania" 84 | '53' "Puerto Rico" 85 | '38' "Rhode Island" 86 | '39' "South Carolina" 87 | '40' "South Dakota" 88 | '41' "Tennessee" 89 | '42' "Texas" 90 | '43' "Utah" 91 | '62' "Virgin Islands" 92 | '45' "Virginia" 93 | '44' "Vermont" 94 | '46' "Washington" 95 | '48' "Wisconsin" 96 | '47' "West Virginia" 97 | '49' "Wyoming" 98 | V6 99 | 'R' "report date" 100 | '' "incident date" 101 | V7 102 | '00' "on or between midnight and 00:59" 103 | '01' "on or between 01:00 and 01:59" 104 | '02' "on or between 02:00 and 02:59" 105 | '03' "on or between 03:00 and 03:59" 106 | '04' "on or between 04:00 and 04:59" 107 | '05' "on or between 05:00 and 05:59" 108 | '06' "on or between 06:00 and 06:59" 109 | '07' "on or between 07:00 and 07:59" 110 | '08' "on or between 08:00 and 08:59" 111 | '09' "on or between 09:00 and 09:59" 112 | '10' "on or between 10:00 and 10:59" 113 | '11' "on or between 11:00 and 11:59" 114 | '12' "on or between 12:00 and 12:59" 115 | '13' "on or between 13:00 and 13:59" 116 | '14' "on or between 14:00 and 14:59" 117 | '15' "on or between 15:00 and 15:59" 118 | '16' "on or between 16:00 and 16:59" 119 | '17' "on or between 17:00 and 17:59" 120 | '18' "on or between 18:00 and 18:59" 121 | '19' "on or between 19:00 and 19:59" 122 | '20' "on or between 20:00 and 20:59" 123 | '21' "on or between 21:00 and 21:59" 124 | '22' "on or between 22:00 and 22:59" 125 | '23' "on or between 23:00 and 23:59" 126 | V13 127 | 'A' "death of offender" 128 | 'B' "prosecution declined (for other than lack of probable cause)" 129 | 'C' "extradition denied" 130 | 'D' "victim refused to cooperate" 131 | 'E' "juvenile/no custody" 132 | 'N' "not applicable" 133 | . 134 | 135 | 136 | 137 | execute 138 | -------------------------------------------------------------------------------- /setup_files/nibrs_batch_header_2.sps: -------------------------------------------------------------------------------- 1 | nibrs_batch_header_2 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.5.0) on 2022-10-07 21:57:59. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1-2 8 | V2 3-4 9 | V3 5-13 10 | V4 14-25 11 | V5 26-34 12 | V6 35-37 13 | V7 38-40 14 | V8 41-49 15 | V9 50-58 16 | V10 59-61 17 | V11 62-64 18 | V12 65-73 19 | V13 74-82 20 | V14 83-85 21 | V15 86-88 22 | V16 89-97 23 | V17 98-106 24 | V18 107-109 25 | V19 110-112 26 | V20 113-121 27 | V21 122-132 28 | . 29 | 30 | variable labels 31 | V1 "segment_level" 32 | V2 "state" 33 | V3 "ori" 34 | V4 "incident_number" 35 | V5 "current_population_1" 36 | V6 "ucr_county_code_1" 37 | V7 "msa_code_1" 38 | V8 "last_population_1" 39 | V9 "current_population_2" 40 | V10 "ucr_county_code_2" 41 | V11 "msa_code_2" 42 | V12 "last_population_2" 43 | V13 "current_population_3" 44 | V14 "ucr_county_code_3" 45 | V15 "msa_code_3" 46 | V16 "last_population_3" 47 | V17 "current_population_4" 48 | V18 "ucr_county_code_4" 49 | V19 "msa_code_4" 50 | V20 "last_population_4" 51 | V21 "blank" 52 | . 53 | 54 | value labels 55 | V2 56 | '50' "Alaska" 57 | '01' "Alabama" 58 | '03' "Arkansas" 59 | '54' "American Samoa" 60 | '02' "Arizona" 61 | '04' "California" 62 | '05' "Colorado" 63 | '06' "Connecticut" 64 | '52' "Canal Zone" 65 | '08' "District of Columbia" 66 | '07' "Delaware" 67 | '09' "Florida" 68 | '10' "Georgia" 69 | '55' "Guam" 70 | '51' "Hawaii" 71 | '14' "Iowa" 72 | '11' "Idaho" 73 | '12' "Illinois" 74 | '13' "Indiana" 75 | '15' "Kansas" 76 | '16' "Kentucky" 77 | '17' "Louisiana" 78 | '20' "Massachusetts" 79 | '19' "Maryland" 80 | '18' "Maine" 81 | '21' "Michigan" 82 | '22' "Minnesota" 83 | '24' "Missouri" 84 | '23' "Mississippi" 85 | '25' "Montana" 86 | '26' "Nebraska" 87 | '32' "North Carolina" 88 | '33' "North Dakota" 89 | '28' "New Hampshire" 90 | '29' "New Jersey" 91 | '30' "New Mexico" 92 | '27' "Nevada" 93 | '31' "New York" 94 | '34' "Ohio" 95 | '35' "Oklahoma" 96 | '36' "Oregon" 97 | '37' "Pennsylvania" 98 | '53' "Puerto Rico" 99 | '38' "Rhode Island" 100 | '39' "South Carolina" 101 | '40' "South Dakota" 102 | '41' "Tennessee" 103 | '42' "Texas" 104 | '43' "Utah" 105 | '62' "Virgin Islands" 106 | '45' "Virginia" 107 | '44' "Vermont" 108 | '46' "Washington" 109 | '48' "Wisconsin" 110 | '47' "West Virginia" 111 | '49' "Wyoming" 112 | . 113 | 114 | 115 | 116 | execute 117 | -------------------------------------------------------------------------------- /setup_files/nibrs_offender_segment.sps: -------------------------------------------------------------------------------- 1 | nibrs_offender_segment 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.5.0) on 2022-10-06 02:55:04. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1-2 8 | V2 3-4 9 | V3 5-13 10 | V4 14-25 11 | V5 26-33 12 | V6 34-35 13 | V7 36-37 14 | V8 38 15 | V9 39 16 | V10 40 17 | . 18 | 19 | variable labels 20 | V1 "segment_level" 21 | V2 "state" 22 | V3 "ori" 23 | V4 "incident_number" 24 | V5 "incident_date" 25 | V6 "offender_sequence_number" 26 | V7 "age_of_offender" 27 | V8 "sex_of_offender" 28 | V9 "race_of_offender" 29 | V10 "ethnicity_of_offender" 30 | . 31 | 32 | value labels 33 | V2 34 | '50' "Alaska" 35 | '01' "Alabama" 36 | '03' "Arkansas" 37 | '54' "American Samoa" 38 | '02' "Arizona" 39 | '04' "California" 40 | '05' "Colorado" 41 | '06' "Connecticut" 42 | '52' "Canal Zone" 43 | '08' "District of Columbia" 44 | '07' "Delaware" 45 | '09' "Florida" 46 | '10' "Georgia" 47 | '55' "Guam" 48 | '51' "Hawaii" 49 | '14' "Iowa" 50 | '11' "Idaho" 51 | '12' "Illinois" 52 | '13' "Indiana" 53 | '15' "Kansas" 54 | '16' "Kentucky" 55 | '17' "Louisiana" 56 | '20' "Massachusetts" 57 | '19' "Maryland" 58 | '18' "Maine" 59 | '21' "Michigan" 60 | '22' "Minnesota" 61 | '24' "Missouri" 62 | '23' "Mississippi" 63 | '25' "Montana" 64 | '26' "Nebraska" 65 | '32' "North Carolina" 66 | '33' "North Dakota" 67 | '28' "New Hampshire" 68 | '29' "New Jersey" 69 | '30' "New Mexico" 70 | '27' "Nevada" 71 | '31' "New York" 72 | '34' "Ohio" 73 | '35' "Oklahoma" 74 | '36' "Oregon" 75 | '37' "Pennsylvania" 76 | '53' "Puerto Rico" 77 | '38' "Rhode Island" 78 | '39' "South Carolina" 79 | '40' "South Dakota" 80 | '41' "Tennessee" 81 | '42' "Texas" 82 | '43' "Utah" 83 | '62' "Virgin Islands" 84 | '45' "Virginia" 85 | '44' "Vermont" 86 | '46' "Washington" 87 | '48' "Wisconsin" 88 | '47' "West Virginia" 89 | '49' "Wyoming" 90 | V6 91 | '00' "unknown" 92 | V7 93 | '00' "unknown" 94 | '99' "over 98 years old" 95 | 'NN' "under 24 hours (neonate)" 96 | 'NB' "1-6 days old" 97 | 'BB' "7-364 days old" 98 | V8 99 | 'M' "male" 100 | 'm' "male" 101 | 'f' "female" 102 | 'F' "female" 103 | 'U' "unknown" 104 | V9 105 | 'W' "white" 106 | 'B' "black" 107 | 'I' "american indian/alaskan native" 108 | 'A' "asian" 109 | 'U' "unknown" 110 | 'P' "native hawaiian or other pacific islander" 111 | 'M' "unknown" 112 | V10 113 | 'H' "hispanic origin" 114 | 'N' "not of hispanic origin" 115 | 'U' "unknown" 116 | . 117 | 118 | 119 | 120 | execute 121 | -------------------------------------------------------------------------------- /setup_files/shr_1976_2021_dta.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/crime_data/8e6eb1ca17319f3d4621049f741d38867481c568/setup_files/shr_1976_2021_dta.zip -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(crimedata) 3 | 4 | test_check("crimedata") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-offenses_known_values.R: -------------------------------------------------------------------------------- 1 | context("test-offenses_known_values") 2 | load("C:/Users/user/Dropbox/R_project/crime_data/clean_data/offenses_known/offenses_known_yearly_1960_2017.rda") 3 | data <- 4 | offenses_known_yearly_1960_2017 %>% 5 | dplyr::filter(year %in% 1985:2014) %>% 6 | dplyr::arrange(year) 7 | 8 | setwd("C:/Users/user/Dropbox/R_project/crime_data/inst/testdata") 9 | alexander_alabama_test <- read_clean_csv_for_tests("alexander_alabama") 10 | fairfield_alabama_test <- read_clean_csv_for_tests("fairfield_alabama") 11 | fort_payne_alabama_test <- read_clean_csv_for_tests("fort_payne_alabama") 12 | birmingham_alabama_test <- read_clean_csv_for_tests("birmingham_alabama") 13 | mobile_alabama_test <- read_clean_csv_for_tests("mobile_alabama") 14 | tuscaloosa_alabama_test <- read_clean_csv_for_tests("tuscaloosa_alabama") 15 | ozark_alabama_test <- read_clean_csv_for_tests("ozark_alabama") 16 | oxford_alabama_test <- read_clean_csv_for_tests("oxford_alabama") 17 | madison_alabama_test <- read_clean_csv_for_tests("madison_alabama") 18 | huntsville_alabama_test <- read_clean_csv_for_tests("huntsville_alabama") 19 | 20 | alexander_alabama_real <- data[data$ori %in% "AL06201" & 21 | data$year %in% alexander_alabama_test$year, ] 22 | fairfield_alabama_real <- data[data$ori %in% "AL00104" & 23 | data$year %in% fairfield_alabama_test$year, ] 24 | fort_payne_alabama_real <- data[data$ori %in% "AL02801" & 25 | data$year %in% fort_payne_alabama_test$year, ] 26 | birmingham_alabama_real <- data[data$ori %in% "AL00102" & 27 | data$year %in% birmingham_alabama_test$year, ] 28 | mobile_alabama_real <- data[data$ori %in% "AL00201" & 29 | data$year %in% mobile_alabama_test$year, ] 30 | tuscaloosa_alabama_real <- data[data$ori %in% "AL06301" & 31 | data$year %in% tuscaloosa_alabama_test$year, ] 32 | ozark_alabama_real <- data[data$ori %in% "AL02601" & 33 | data$year %in% ozark_alabama_test$year, ] 34 | oxford_alabama_real <- data[data$ori %in% "AL01105" & 35 | data$year %in% oxford_alabama_test$year, ] 36 | madison_alabama_real <- data[data$ori %in% "AL04702" & 37 | data$year %in% madison_alabama_test$year, ] 38 | huntsville_alabama_real <- data[data$ori %in% "AL04701" & 39 | data$year %in% huntsville_alabama_test$year, ] 40 | 41 | 42 | test_that("Offenses known values are accurate - same as ucrdatatool.gov", { 43 | 44 | # Alexander Alabama 45 | expect_equal(alexander_alabama_real$population, 46 | alexander_alabama_test$population) 47 | expect_equal(alexander_alabama_real$actual_murder, 48 | alexander_alabama_test$murder) 49 | expect_equal(alexander_alabama_real$actual_rape_total, 50 | alexander_alabama_test$rape) 51 | expect_equal(alexander_alabama_real$actual_robbery_total, 52 | alexander_alabama_test$robbery) 53 | expect_equal(alexander_alabama_real$actual_assault_aggravated, 54 | alexander_alabama_test$aggravated_assault) 55 | expect_equal(alexander_alabama_real$actual_burg_total, 56 | alexander_alabama_test$burglary) 57 | expect_equal(alexander_alabama_real$actual_theft_total, 58 | alexander_alabama_test$theft) 59 | expect_equal(alexander_alabama_real$actual_mtr_veh_theft_total, 60 | alexander_alabama_test$motor_vehicle_theft) 61 | 62 | # Fairfield Alabama 63 | expect_equal(fairfield_alabama_real$population, 64 | fairfield_alabama_test$population) 65 | expect_equal(fairfield_alabama_real$actual_murder, 66 | fairfield_alabama_test$murder) 67 | expect_equal(fairfield_alabama_real$actual_rape_total, 68 | fairfield_alabama_test$rape) 69 | expect_equal(fairfield_alabama_real$actual_robbery_total, 70 | fairfield_alabama_test$robbery) 71 | expect_equal(fairfield_alabama_real$actual_assault_aggravated, 72 | fairfield_alabama_test$aggravated_assault) 73 | expect_equal(fairfield_alabama_real$actual_burg_total, 74 | fairfield_alabama_test$burglary) 75 | expect_equal(fairfield_alabama_real$actual_theft_total, 76 | fairfield_alabama_test$theft) 77 | expect_equal(fairfield_alabama_real$actual_mtr_veh_theft_total, 78 | fairfield_alabama_test$motor_vehicle_theft) 79 | 80 | 81 | # Fort Payne Alabama 82 | expect_equal(fort_payne_alabama_real$population, 83 | fort_payne_alabama_test$population) 84 | expect_equal(fort_payne_alabama_real$actual_murder, 85 | fort_payne_alabama_test$murder) 86 | expect_equal(fort_payne_alabama_real$actual_rape_total, 87 | fort_payne_alabama_test$rape) 88 | expect_equal(fort_payne_alabama_real$actual_robbery_total, 89 | fort_payne_alabama_test$robbery) 90 | expect_equal(fort_payne_alabama_real$actual_assault_aggravated, 91 | fort_payne_alabama_test$aggravated_assault) 92 | expect_equal(fort_payne_alabama_real$actual_burg_total, 93 | fort_payne_alabama_test$burglary) 94 | expect_equal(fort_payne_alabama_real$actual_theft_total, 95 | fort_payne_alabama_test$theft) 96 | expect_equal(fort_payne_alabama_real$actual_mtr_veh_theft_total, 97 | fort_payne_alabama_test$motor_vehicle_theft) 98 | }) 99 | 100 | 101 | 102 | 103 | 104 | 105 | # Cleared crimes from crime data explorer --------------------------------- 106 | 107 | # test_that("cleared murder", { 108 | # 109 | # expect_equal(alexander_alabama$actual_murder, c()) 110 | # }) 111 | # 112 | # 113 | # test_that("cleared rape", { 114 | # 115 | # expect_equal(alexander_alabama$tot_clr_murder, c()) 116 | # 117 | # }) 118 | # 119 | # test_that("cleared robbery", { 120 | # 121 | # expect_equal(alexander_alabama$tot_clr_robbery_total, c()) 122 | # 123 | # }) 124 | # 125 | # test_that("cleared aggravated assault", { 126 | # 127 | # expect_equal(alexander_alabama$tot_clr_aggravated_assault, c()) 128 | # 129 | # }) 130 | # 131 | # test_that("cleared burglary", { 132 | # 133 | # expect_equal(alexander_alabama$tot_clr_burg_total, c()) 134 | # 135 | # }) 136 | # 137 | # test_that("cleared theft", { 138 | # 139 | # expect_equal(alexander_alabama$tot_clr_theft_total, c()) 140 | # 141 | # }) 142 | # 143 | # test_that("cleared motor vehicle", { 144 | # 145 | # expect_equal(alexander_alabama$tot_clr_mtr_veh_theft_total, c()) 146 | # 147 | # }) 148 | --------------------------------------------------------------------------------