R/make_sps/nibrs_victim_segment_sps.R

source(here::here('R/make_sps/make_sps_utils.R'))
source(here::here('R/make_sps/nibrs_sps_utils.R'))
# Page 62-69


col_positions <- c("1-2",
                   "3-4",
                   "5-13",
                   "14-25",
                   "26-33",
                   "34-36",
                   "37-39",
                   "40-42",
                   "43-45",
                   "46-48",
                   "49-51",
                   "52-54",
                   "55-57",
                   "58-60",
                   "61-63",
                   "64-66",
                   "67",
                   "68-69",
                   "70",
                   "71",
                   "72",
                   "73",
                   "74-75",
                   "76-77",
                   "78",
                   "79",
                   "80",
                   "81",
                   "82",
                   "83",
                   "84-85",
                   "86-87",
                   "88-89",
                   "90-91",
                   "92-93",
                   "94-95",
                   "96-97",
                   "98-99",
                   "100-101",
                   "102-103",
                   "104-105",
                   "106-107",
                   "108-109",
                   "110-111",
                   "112-113",
                   "114-115",
                   "116-117",
                   "118-119",
                   "120-121",
                   "122-123",
                   "124-125",
                   "126",
                   "127-135")

col_labels <- c("segment_level",
                "state",
                "ori",
                "incident_number",
                "incident_date",
                "victim_sequence_number",
                repeated_label_replace_fixer("ucr_offense_code_replace",
                                             1:10),
                "type_of_victim",
                "age_of_victim",
                "sex_of_victim",
                "race_of_victim",
                "ethnicity_of_victim",
                "resident_status_of_victim",
                "agg_assault_homicide_circumsta1",
                "agg_assault_homicide_circumsta2",
                "addit_just_homicide_circumsta",
                repeated_label_replace_fixer("type_of_injury_replace",
                                             1:5),
                repeated_label_replace_fixer(
                  c("offender_number_to_be_relatedreplace",
                    "relation_of_vict_to_offenderreplace"),
                  1:10),
                "officer_type_activity",
                "officer_assignment_type",
                'officer_killed_other_agency_ori')




nibrs_victim_value_labels <-
  c(state_value_labels,
    repeated_label_replace_fixer(ucr_offense_code_value_labels_replace,
                                 1:10),
    "type_of_victim = ",
    "I = individual",
    "B = business",
    "F = financial institution",
    "G = government",
    "R = religious organization",
    "S = society/public",
    "O = other",
    "U = unknown",
    # From NACJD 2016 victim segment file
    "L = law enforcement officer",
    gsub("replace", "victim", age_sex_race_ethnicity),
    "resident_status_of_victim = ",
    "R = resident",
    "N = nonresident",
    "U = unknown",
    "addit_just_homicide_circumsta = ",
    "A = criminal attacked police officer and that officer killed criminal",
    "B = criminal attacked police officer and criminal killed by another police officer",
    "C = criminal attacked a civilian",
    "D = criminal attempted flight from a crime",
    "E = criminal killed in commission of a crime",
    "F = criminal resisted arrest",
    "G = unable to determine/not enough information",
    repeated_label_replace_fixer(
      c("agg_assault_homicide_circumstareplace = ",
        # Aggravated assault/murder
        "01 = argument",
        "02 = assault on law enforcement officer(s)",
        "03 = drug dealing",
        "04 = gangland",
        "05 = juvenile gang",
        "06 = domestic violence (historically called lovers triangle/quarrel)",
        "07 = mercy killing",
        "08 = other felony involved",
        "09 = other circumstances",
        "10 = unknown circumstances",
        # Negligent manslaughter
        "30 = child playing with weapon",
        "31 = gun-cleaning accident",
        "32 = hunting accident",
        "33 = other negligent weapon handling",
        "34 = other negligent killings",
        # Justifiable homicide
        "20 = criminal killed by private citizen",
        "21 = criminal killed by police officer"),
      1:2),
    repeated_label_replace_fixer(c("type_of_injury_replace = ",
                                   "N = none",
                                   "M = apparent minor injuries",
                                   "B = apparent broken bones",
                                   "O = other major injury",
                                   "I = possible internal injury",
                                   "T = loss of teeth",
                                   "L = severe laceration",
                                   "U = unconsciousness"),
                                 1:5),
    repeated_label_replace_fixer(c("relation_of_vict_to_offenderreplace = ",
                                   # Within family
                                   "SE = victim was spouse",
                                   "CS = victim was common-law spouse",
                                   "PA = victim was parent",
                                   "SB = victim was sibling",
                                   "CH = victim was child",
                                   "GP = victim was grandparent",
                                   "GC = victim was grandchild",
                                   "IL = victim was in-law",
                                   "SP = victim was step-parent",
                                   "SC = victim was step-child",
                                   "SS = victim was step-sibling",
                                   "OF = victim was other family member",
                                   "VO = victim was offender",
                                   # Outside family but known to victim
                                   "AQ = victim was acquaintance",
                                   "FR = victim was friend",
                                   "NE = victim was neighbor",
                                   "BE = victim was babysittee (the baby)",
                                   "BG = victim was boyfriend/girlfriend",
                                   "CF = victim was child of boyfriend/girlfriend",
                                   "HR = victim was in a homosexual relationship with the offender",
                                   "XS = victim was ex-spouse",
                                   "EE = victim was employee",
                                   "ER = victim was employer",
                                   "OK = victim was otherwise known",
                                   # Not known by victim
                                   "RU = relationship unknown",
                                   "ST = victim was stranger",
                                   # FROM NIBRS codebook
                                   "XR = victim was ex-relationship (ex-boyfriend/ex-girlfriend)"),
                                 1:10),
    "officer_type_activity = ",
    "01 = responding to disturbance call (domestic violence, person with firearm, etc.)",
    "02 = burglary in progress/pursuing burglary suspect",
    "03 = robbery in progress/pursuing robbery suspect",
    "04 = attempting other arrest",
    "05 = civil disorder (e.g. riot, mass disobedience)",
    "06 = handling/transporting/custody of prisoner(s)",
    "07 = investigating suspicious persons/circumstances",
    "08 = ambush - no warning",
    "09 = mentally deranged assailant",
    "10 = traffic pursuits and stops",
    "11 = all other",
    "officer_assignment_type = ",
    "F = two-officer vehicle",
    "G = one-officer vehicle (alone)",
    "H = one-officer vehicle (assisted)",
    "I = detective or special assignment (alone)",
    "J = detective or special assignment (assisted)",
    "K = other (alone)",
    "L = other (assisted)")




setwd(here::here("setup_files"))
make_sps_setup(file_name     = "nibrs_victim_segment",
               col_positions = col_positions,
               col_labels    = col_labels,
               value_labels  = nibrs_victim_value_labels)
jacobkap/crime_data documentation built on April 16, 2023, 11:58 p.m.